[英]InnoSetup - Check if visual studio 2010 crt redist is installed, if not then run installer
I currently have this in this part of Inno script 我目前在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...
It will run vcredist installer during app installation. 它将在应用程序安装期间运行vcredist安装程序。 But the problem with this is that if the user has it already installed it throws things like
但问题是,如果用户已安装它,它会抛出类似的东西
Is there any way to avoid this and only run this installer if needed? 有没有办法避免这种情况,只在需要时运行此安装程序? What should i add to Inno script?
我应该在Inno脚本中添加什么?
EDIT: 编辑:
With the help of @John links i made it witht he following function added 在@John链接的帮助下,我做了以下功能
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. 我还使用这个站点进行参考,获取visual studio 2010 crt ++产品代码,并在注册表中使用Uninstall文件夹来检测它是否已安装。
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...
but this is still good enough. 但这仍然足够好。
I follow the "official" MS way https://stackoverflow.com/a/199783/866333 . 我遵循“官方”MS方式https://stackoverflow.com/a/199783/866333 。 Not exactly gone viral yet but it works for me.
还没有完全病毒化,但它对我有用。
See Inno Setup: Verify that .NET 4.0 is installed for working code to detect just one version. 请参阅Inno设置:验证是否已安装.NET 4.0以使工作代码仅检测一个版本。
This is the best example of the code I actually use: http://www.vincenzo.net/isxkb/index.php?title=.NET_-_Detect_framework 这是我实际使用的代码的最佳示例: http : //www.vincenzo.net/isxkb/index.php?title = .NET_-_ Detect_framework
All the above targets the .NET framework. 以上所有都是针对.NET框架的。 For VCRT I would extract the redistributable from VC2010 and have InnoSetup copy the contents over to the application's target install directory.
对于VCRT,我将从VC2010中提取可再发行组件,并让InnoSetup将内容复制到应用程序的目标安装目录。 That way system files don't get altered.
这样系统文件不会被改变。
Follow this link https://www.codeproject.com/Articles/20868/NET-Framework-Installer-for-InnoSetup . 请点击此链接https://www.codeproject.com/Articles/20868/NET-Framework-Installer-for-InnoSetup 。 Its for both NET framework and VC distributables.You can find out if there is a distributable, say 2013, is installed in a pc or not.
它适用于.NET框架和VC可循环使用。您可以查看是否有可分发的,例如2013,是否安装在PC中。 If not installed, it will install it for you.
如果没有安装,它将为您安装。 I HIGHLY RECOMMEND this.
我强烈推荐这个。
Maybe you can use HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\SharedDLLs. 也许你可以使用HKLM \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ SharedDLLs。 You can found all versions has been installed.
您可以找到已安装的所有版本。 DLL has special name depends of c++ Retribuitable installation:
DLL有特殊名称取决于c ++ Retribuitable安装:
90: Visual Studio 2008 (Version 9.0) (atl90.dll, msvcr90.dll, msvcp90.dll) 90:Visual Studio 2008(版本9.0)(atl90.dll,msvcr90.dll,msvcp90.dll)
100: Visual Studio 2010 (Version 10.0) (atl100.dll, msvcr100.dll, msvcp100.dll) 100:Visual Studio 2010(版本10.0)(atl100.dll,msvcr100.dll,msvcp100.dll)
110: Visual Studio 2012 (Version 11.0) …110 110:Visual Studio 2012(版本11.0)... 110
120: Visual Studio 2013 (Version 12.0) …120 120:Visual Studio 2013(版本12.0)... 120
140: Visual Studio 2015 (Version 14.0) …140 140:Visual Studio 2015(版本14.0)... 140
150: Visual Studio 2017 (Version 15.0) (atl150.dll, msvcr150.dll, msvcp150.dll) 150:Visual Studio 2017(15.0版)(atl150.dll,msvcr150.dll,msvcp150.dll)
160: Visual Studio 2019 (Version 16.0) (atl160.dll, msvcr160.dll, msvcp160.dll) 160:Visual Studio 2019(版本16.0)(atl160.dll,msvcr160.dll,msvcp160.dll)
Regards, 问候,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.