使用Inno Setup检查Chrome是否已安装且是否为特定版本

时间:2016-11-30 07:24:15

标签: inno-setup

我们的软件需要谷歌浏览器版本54.00及以上版本。

因此我想让我的应用程序安装脚本首先检查计算机中是否有Chrome浏览器可用,如果不是他们那么它应该默认安装chrome版本54.00离线(将提供chrome脱机安装文件在它自己的包中,如果计算机中已经安装了chrome,那么安装脚本应检查chrome版本是否为54.00及以上,如果是,那么如果版本低于54.00我们的软件安装应该继续进行,那么它应该从包中提供的chrome安装文件安装或更新到v54.00。

对Chrome安装的检查应该在我的软件安装过程开始时进行。

此外,如果有人帮我提供有关inno的任何教程,可以通过一些细节方式在线获取,这将对我有所帮助。

我们现有的安装脚本如下: -

enter center code herode here
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "CLIxModules_v1.0.9"
#define MyAppVersion "1.0.9"
#define MyAppPublisher "Connected Learning Initiative, Tata Institute Of  Social Science"
#define MyAppURL "https://clix.tiss.edu" 
#define MyAppExeName "unplatform_win32_ssl.bat"

[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={{2154FF98-4E99-44A6-9EE9-56886A9BA8EF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={userdocs}\{#MyAppName}
DisableProgramGroupPage=yes
OutputDir=A:\CLIX\FINAL RELEASED VERSIONS\Release1811
OutputBaseFilename=CLIxModules_v1.0.9_setup
SetupIconFile=A:\CLIX\Packaged\CLIxModules_v1.0.9_Packaged_1711\CLIxModules_v1.0.9\Clix_Setup_Icon.ico
Compression=lzma
SolidCompression=yes
PrivilegesRequired=lowest

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

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

[Files]
Source: "A:\CLIX\Packaged\CLIxModules_v1.0.9_Packaged_1711\CLIxModules_v1.0.9\unplatform_win32_ssl.bat"; DestDir: "{app}"; Flags: ignoreversion
Source: "A:\CLIX\Packaged\CLIxModules_v1.0.9_Packaged_1711\CLIxModules_v1.0.9\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: {app}/clix_round_icons_core_RFY_icon.ico

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

1 个答案:

答案 0 :(得分:0)

您的问题非常广泛,没有说明,您想要检查和安装Chrome等的安装部分。

但是为了给你一些想法,请参阅下面的代码。

该代码使用Inno Setup - How can I tell the installation when it execute Google Chrome, it should open stackoverflow.com?中的GetChromeFileName函数。该答案还显示了使用[Run]部分条目和{{1}检查Chrome并执行其安装程序的不同方法参数。

Check

在您需要的地方拨打[Files] Source: "ChromeStandaloneSetup64.exe"; Flags: dontcopy nocompression [Code] procedure CheckChrome; var ChromeMS, ChromeLS: Cardinal; ChromeMajorVersion, ChromeMinorVersion: Cardinal; InstallChrome: Boolean; ChromeFileName: string; ChromeInstallerFileName: string; ResultCode: Integer; begin ChromeFileName := GetChromeFileName(''); if ChromeFileName = '' then begin Log('Chrome not found, will install'); InstallChrome := True; end else begin Log(Format('Found Chrome path %s', [ChromeFileName])); if not GetVersionNumbers(ChromeFileName, ChromeMS, ChromeLS) then begin Log(Format('Cannot read Chrome version from %s, will install', [ChromeFileName])); InstallChrome := True; end else begin ChromeMajorVersion := ChromeMS shr 16; ChromeMinorVersion := ChromeMS and $FFFF; Log(Format('Chrome version is %d.%d', [ChromeMajorVersion, ChromeMinorVersion])); if ChromeMajorVersion < 53 then begin Log('Chrome is too old, will install'); InstallChrome := True; end else begin Log('Chrome is up to date, will not install'); InstallChrome := False; end; end; end; if InstallChrome then begin Log('Installing Chrome'); ExtractTemporaryFile('ChromeStandaloneSetup64.exe'); ChromeInstallerFileName := ExpandConstant('{tmp}\ChromeStandaloneSetup64.exe'); Exec(ChromeInstallerFileName, '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode); { add some error checking here} Log('Installed Chrome'); end; end; 。例如。在InitializeSetupCurStepChanged中:

CheckChrome