Innosetup 多种安装 vc_redist 运行库方式

很多程序需要安装vc运行库才能正常用,那就需要安装两个exe,让用户选是否安装就选普通方式,如果无须用户选择,直接安装就选择全静默方式。 以下用vc_redist.x64.exe举栗子。

一、普通、半静默、全静默安装

[Files]
Source: “vc_redist.x64.exe”; DestDir: {app}; Flags: deleteafterinstall

1、普通安装vc_redist.x64.exe,即提示用户是否安装
[Run]
Filename:{app}vc_redist.x64.exe";

2、半静默状态安装vc_redist.x64.exe,即提示正在安装 Installing Microsoft Visual C++ Runtime
[Run]
Filename: “{app}\vc_redist.x64.exe”; Parameters: “/q /passive /Q:a /c:”“msiexec /q /i vcredist.msi”""; StatusMsg: “Installing Microsoft Visual C++ Runtime …”; Flags: skipifdoesntexist;

3、全静默状态安装vc_redist.x64.exe,即没有提示,直接安装
[Run]
Filename: “{app}\vc_redist.x64.exe”; Parameters: “/q”; StatusMsg: “Installing Microsoft Visual C++ Runtime …”; Flags: skipifdoesntexist;

二、检测是否已安装,否则全静默安装

[Files]
Source: vc_redist.x64.exe"; DestDir: “{app}”; Check: NeedInstallVC9SP1

[Run]
Filename: “{app}{#AppExeName}”; Description: “{#AppExeName}”; Flags: nowait postinstall skipifsilent
Filename: “{app}\vc_redist.x64.exe”; Parameters: /q; StatusMsg: “Installing Microsoft Visual C++ Runtime …”; Flags: skipifdoesntexist;Check: NeedInstallVC9SP1

[Code]
var vc9SP1Missing: Boolean;
function NeedInstallVC9SP1(): Boolean;
begin
Result := vc9SP1Missing;
end;
function InitializeSetup(): Boolean;
var version: Cardinal;
begin
if RegQueryDWordValue(HKLM, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{9A25302D-30C0-39D9-BD6F-21E6EC160475}’, ‘Version’, version) = false then begin
vc9SP1Missing := true;
end;
result := true;
end;

你可能感兴趣的:(innosetup,exe,脚本语言)