按照 Inno Setup6.2.0汉化版软件及生成安装脚本(二)
的安装包安装后可以安装以下脚本进行更新,会自动识别版本,关闭服务,关闭打开的客户端,更新客户端,最后启动服务。
//定义常量 #define MyAppId "08FBA954-A306-4782-8C02-05F3DFE01772" #define MyAppName "客户端名称" #define OldMyAppVersion "1.0.0.0" #define MyAppVersion "1.0.0.1" #define MyAppPublisher "公司名称" #define MyAppURL "公司网址" #define MyAppExeName "Client.exe" #define MyAppAssocName MyAppName + " 文件" #define MyAppAssocExt ".exe" #define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt [Setup] //AppId的值为单独标识该应用程序。不要为其他安装程序使用相同的AppId值。 若要生成新的 GUID,可在菜单中点击 "工具|生成 GUID"。
//更新包的AppId一定要和安装包的AppId一样 AppId={{08FBA954-A306-4782-8C02-05F3DFE01772} //应用程序名称 AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={autopf}\{#MyAppName} ChangesAssociations=yes DisableProgramGroupPage=yes InfoBeforeFile=E:\JCY\JCY_DATA\MPC\HL\KWB\TMT\V101.24\01CHIP\TMT\安装说明.txt ; 以下行取消注释,以在非管理安装模式下运行(仅为当前用户安装)。 ;PrivilegesRequired=lowest OutputBaseFilename=VISOUpdate SetupIconFile=E:\JCY\JCY_DATA\MPC\HL\KWB\TMT\V101.24\01CHIP\TMT\viso.ico Compression=lzma SolidCompression=yes WizardStyle=modern ArchitecturesInstallIn64BitMode=x64 ;[Languages] ;Name: "chinesesimp"; MessagesFile: "compiler:Default.isl" ;Name: "english"; MessagesFile: "compiler:Languages\English.isl" ;[Tasks] ;Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked ;[Icons] ;Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" ;Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Files] Source: "E:\Update\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion Source: "E:\Update\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ;安装文件太多,不全部标识引用 ; ; ; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion” [Run] Filename: "{app}\Server\open.bat"; Flags: runhidden [Code] //安装时判断系统中是否已安装该软件以前版本 function InitializeSetup(): Boolean; var strVer: String; isRunning:Integer; cycleCount:Integer; ResultCode: Integer; begin Result := true; if Is64BitInstallMode then //是64位操作系统 begin if RegQueryStringValue(HKA,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1', 'DisplayVersion', strVer) then begin if not (strVer='{#OldMyAppVersion}') then begin MsgBox('软件版本号错误:'#13#10#13#10'1.0.0.1 升级仅支持1.0.0.0 版本!', mbInformation, MB_OK); Result := False; end else if not RegKeyExists(HKA, 'Software\Classes\Applications\{#MyAppExeName}\YourClient2023') then begin MsgBox('系统没有安装 1.0.0.0原版程序!'#13#10#13#10'请先安装原版程序后,再运行本更新程序!', mbInformation, MB_OK); Result := False; end else begin if RegQueryStringValue(HKA,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1', 'InstallLocation', strVer) then begin if Exec(ExpandConstant(strVer+'Server\close.bat'), '/silent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin // 批处理文件成功执行 // 可以在这里添加相应的逻辑 end else begin // 批处理文件执行出错 // 可以在这里添加相应的逻辑 end; end end; end else begin MsgBox('系统没有安装 1.0.0.0原版程序!'#13#10#13#10'请先安装原版程序后,再运行本更新程序!!', mbInformation, MB_OK); Result := False; end; end else //是32位操作系统 begin if RegQueryStringValue(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1', 'DisplayVersion', strVer) then begin if not (strVer='{#OldMyAppVersion}') then begin MsgBox('软件版本号错误:'#13#10#13#10'1.0.0.1 升级仅支持 1.0.0.0 版本!', mbInformation, MB_OK); Result := False; end else if not RegKeyExists(HKLM, 'Software\Classes\Applications\{#MyAppExeName}\YourClient2023') then begin MsgBox('系统没有安装 1.0.0.0原版程序!'#13#10#13#10'请先安装原版程序后,再运行本更新程序!', mbInformation, MB_OK); Result := False; end; end else begin MsgBox('系统没有安装 1.0.0.0原版程序!'#13#10#13#10'请先安装原版程序后,再运行本更新程序!!', mbInformation, MB_OK); Result := False; end; end; end;
标签:10,更新包,end,Setup6.2,汉化版,begin,1.0,13,define From: https://www.cnblogs.com/js-jiangchenyang/p/17869724.html