使用Inno安装程序检查是否已安装Chrome并具有特定版本 [英] Checking if Chrome is installed and is of specific version using Inno Setup

查看:65
本文介绍了使用Inno安装程序检查是否已安装Chrome并具有特定版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个需要Google Chrome版本54.00及更高版本的软件.

We have a software that need google chrome version 54.00 and above.

因此,我想使用我的应用程序安装脚本来首先检查chrome浏览器是否在计算机中可用,如果不是,那么它应该以静默方式离线安装chrome版本54.00(将提供chrome离线安装文件(如果是,请自行包装),如果计算机中已经安装了chrome,则安装脚本应检查chrome版本是否为54.00或更高(如果是),则应继续进行我们的软件安装;否则,如果版本低于54.00,则应进行安装从包装中提供的chrome设置文件中安装或更新到v54.00.

Hence i want to make my application installation script to first check if the chrome browser is available or not in the computer then if it is not their then it should silently install the chrome version 54.00 offline(chrome offline installation file will be provided in the package it self), if the chrome is already installed in the computer then the installation script should check if the chrome version is 54.00 and above if yes then our software installation should be proceeded else if the version is lower than 54.00 then it should install or update to v54.00 from the chrome setup file provided in the package.

Chrome浏览器安装检查应在我的软件安装过程开始时进行.

This check for the chrome installation should be at the start of the installation process of my software.

如果有人和我在网上提供一些有关inno的教程,并且能以一点点细节的方式帮助我,也会对我有很大帮助.

Also if anybody and help me with any tutorial about inno that is available online in a little detail manner will help me a lot.

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

The present installation script which we are having is as below :-

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

推荐答案

您的问题很广泛,它没有指定要检查并安装Chrome的安装的哪一部分,等等.

Your question is pretty broad, it does not specify, in what part of the installation you want to check for and install Chrome, etc.

但是,请给您一些想法,请参见下面的代码.

But to give you some idea, see the code below.

代码使用 Inno设置中的GetChromeFileName功能-执行安装Chrome浏览器时如何告诉安装,它应该打开stackoverflow.com?该答案还显示了使用[Run]部分条目和Check参数检查Chrome并执行其安装程序的另一种方法.

The code uses the GetChromeFileName function from Inno Setup - How can I tell the installation when it execute Google Chrome, it should open stackoverflow.com? That answer also shows a different approach to checking for Chrome and executing its installer, using the [Run] section entry and the Check parameter.

[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;


在需要的地方致电CheckChrome.例如.在 InitializeSetup


Call the CheckChrome, where you need it. E.g. in InitializeSetup or CurStepChanged:

function InitializeSetup(): Boolean;
begin
  CheckChrome;
  Result := True;
end;

这篇关于使用Inno安装程序检查是否已安装Chrome并具有特定版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆