我想用Inno Setup创建安装文件

时间:2014-10-03 17:43:55

标签: windows installer installation inno-setup

我需要Inno Setup的帮助。首先,我想对我的英语感到抱歉。我希望你理解我。

我有这个脚本:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "My software - BETA"
#define MyAppVersion "1.5"
#define MyAppExeName "My software.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{009E8058-565E-43F7-BEAD-34E283BCA6F4}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
LicenseFile=D:\My software\EULA.rtf
OutputBaseFilename=My software - Setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "D:\My software\My software.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My software\settings.txt"; DestDir: "{userappdata}\My software"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

设置有效,但我想在设置中添加几个选项:

1)如果软件已经安装,那么我想这将是一个选项,使用户能够选择是否覆盖以前的设置.. 类似于复选框:"不要覆盖之前的设置" 默认情况下,安装程序不会覆盖以前的设置。

2)在卸载程序中,我想要选项:"同时删除设置" (类似的东西),默认情况下,此选项未选中

3)我想要选项"创建一个桌面图标"将始终默认选中。 我注意到,只有在之前已创建图标时,默认情况下才会选中此选项。

感谢帮助! 吉尔。

1 个答案:

答案 0 :(得分:0)

您的问题的答案:

1 - 如果您要安装已安装的应用程序,则应该让用户卸载  选项。要保留上一个设置,您可以Flags: onlyifdoesntexist使用[Files],或

Flags: createvalueifdoesntexist [Registry]

2 - 将以下code放入[Code]部分,它应该允许用户删除设置选项。

[Code]
procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
var
  mres : integer;
begin
  case CurUninstallStep of
    usPostUninstall:
      begin
        mres := MsgBox('Do you want to Remove Settings?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
        if mres = IDYES then
          DelTree(ExpandConstant('{userdocs}\Myapp'), True, True, True);
      end;
  end;
end;

3 - 如果您想要检查图标任务,请从Flags: unchecked部分删除[Task]部分。