InnoSetup-检查是否安装了Visual Studio 2010 crt redist,如果未安装,则运行安装程序 [英] InnoSetup - Check if visual studio 2010 crt redist is installed, if not then run installer
问题描述
我目前在Inno脚本的这一部分中有这个
I currently have this in this part of Inno script
[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安装程序。但是问题在于,如果用户已经安装了它,则会抛出
It will run vcredist installer during app installation. But the problem with this is that if the user has it already installed it throws things like
- 修复/删除 $ b $之类的东西。 b
- 已检测到较新版本
- Repair/Remove
- Already newer version detected
有什么方法可以避免这种情况,仅在需要时运行此安装程序?我应该在Inno脚本中添加什么?
Is there any way to avoid this and only run this installer if needed? What should i add to Inno script?
编辑:
借助@John链接,我做到了添加了以下功能
With the help of @John links i made it witht he following function added
我还使用了此站点供参考,以获取Visual Studio 2010 crt ++产品代码,并使用注册表中的Uninstall文件夹来检测其是否已安装。
I also used this site for refference to get visual studio 2010 crt++ product code and used Uninstall folder in registry to detect if its installed.
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;
如果安装程序在下载/安装后仍可以继续运行,或者我可以以某种方式适应先前运行的包含安装程序的代码(带有安装程序):
It would still be nice if however installer would continue after downloading/installing or that i could somehow adapt my previous code that runs included(with setup) installer:
[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...
但这还是足够好。 p>
but this is still good enough.
推荐答案
我遵循官方 MS方式 https://stackoverflow.com/a/199783/866333 。
I follow the "official" MS way https://stackoverflow.com/a/199783/866333. Not exactly gone viral yet but it works for me.
请参见 Inno设置:验证是否已安装.NET 4.0 用于工作代码以仅检测一个版本。
See Inno Setup: Verify that .NET 4.0 is installed for working code to detect just one version.
此是我实际使用的代码的最佳示例: http:// www.vincenzo.net/isxkb/index.php?title=.NET_-_Detect_framework
This is the best example of the code I actually use: http://www.vincenzo.net/isxkb/index.php?title=.NET_-_Detect_framework
以上所有内容均针对.NET框架。对于VCRT,我将从VC2010中提取可再发行文件,并让InnoSetup将内容复制到应用程序的目标安装目录中。这样系统文件就不会被更改。
All the above targets the .NET framework. For VCRT I would extract the redistributable from VC2010 and have InnoSetup copy the contents over to the application's target install directory. That way system files don't get altered.
这篇关于InnoSetup-检查是否安装了Visual Studio 2010 crt redist,如果未安装,则运行安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!