我目前在 Inno 脚本的这一部分中有这个
[Run]
Filename: {app}\bin\vcredist_x86.exe; Parameters: "/q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; WorkingDir: {app}\bin; StatusMsg: Installing Visual Studio 2010 C++ CRT Libraries...
它将在应用程序安装过程中运行 vcredist 安装程序。但这样做的问题是,如果用户已经安装了它,它会抛出类似的东西
有什么方法可以避免这种情况并且仅在需要时运行此安装程序?我应该在 Inno 脚本中添加什么?
EDIT:
在@John链接的帮助下,我添加了以下功能
我也用过这个网站参考获取 Visual Studio 2010 C++ 产品代码并使用注册表中的卸载文件夹来检测其是否已安装。
function InitializeSetup(): Boolean;
var
ErrorCode: Integer;
RedistInstalled : Boolean;
Result1 : Boolean;
begin
RedistInstalled := RegKeyExists(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{196BB40D-1578-3D01-B289-BEFC77A11A1E}');
if RedistInstalled then
begin
Result := true;
end else
begin
RedistInstalled := RegKeyExists(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{196BB40D-1578-3D01-B289-BEFC77A11A1E}');
if RedistInstalled then
begin
Result := true;
end else
begin
Result1 := MsgBox('This setup requires Microsoft Visual C++ 2010 Redistributable Package (x86). Please install Visual C++ 2010 Redistributable Package (x86) and run this setup again. '#13#10' '#13#10'Do you want to download Microsoft Visual C++ 2010 Redistributable Package (x86) now?',
mbConfirmation, MB_YESNO) = idYes;
if Result1 =false then
begin
Result:=false;
end else
begin
Result:=false;
ShellExec('open',
'http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe',
'','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
end;
end;
end;
end;
但是,如果安装程序在下载/安装后继续,或者我可以以某种方式调整我之前运行的包含(安装)安装程序的代码,那就太好了:
[Run]
Filename: {app}\bin\vcredist_x86.exe; Parameters: "/q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; WorkingDir: {app}\bin; StatusMsg: Installing Visual Studio 2010 C++ CRT Libraries...
但这仍然足够好了。