任何人都有在INNO脚本中安装之前如何安装.NET框架的想法?使用Inno setup与我的应用程序一起安装.Net框架
3
A
回答
2
您可以use a [Run]
section启动一个可执行文件。可重新分发的.NET安装程序是可执行文件。例如,您可以download the installer for .NET 2.0 here。请参阅Inno Setup documentation。
0
这里是一个可能的解决方案,在InitializeWizard()方法中,你需要在注册表中检查你需要的.net框架的特定版本,如果它不存在,那么你可以包含,作为你inno的一部分安装程序和框架Web安装程序,然后您可以执行它,然后等待它结束,并根据它是否成功安装,您可以选择继续安装或中止安装。
另外,请记住,某些.net框架安装程序在安装后可能需要重新启动,在这种情况下,您也可能希望在注册表中包含运行键或运行键下的密钥,以便您的安装程序在重新启动后被调用(如果用户选择在安装后立即重新启动)。
下面是这样一个例子:我觉得你还是需要找到一种方式来获得执行安装程序的路径,如果你想设置注册表中的关键,但是除了
function CheckIfFrameworkNeeded(): Boolean;
var
VersionFrameWork: Cardinal;
FrameWorkNeeded: Boolean;
begin
FrameWorkNeeded := true;
//**********************************************************************
// Check Fot Framewok 3.5.
//**********************************************************************
if (RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v3.5', 'Install', VersionFrameWork)) then
begin
if (VersionFrameWork = 1) then
FrameWorkNeeded := false
end;
Result := FrameWorkNeeded;
end;
function Install_NETFramework() : Integer;
var
hWnd: Integer;
ResultCode: Integer;
dotnetRedistPath: string;
outVar : string;
begin
dotnetRedistPath:= ExpandConstant('{tmp}\dotnetfx35setup.exe');
//*********************************************************************************
// Run the install file for .NET Framework 3.5. This is usually dotnetfx35setup.exe from MS
//***********************************************************************************
if Exec(ExpandConstant(dotnetRedistPath), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// ResultCode contains the exit code
case ResultCode of
// 1641 The requested operation completed successfully. The system will be restarted so the changes can take effect.
// 3010 The requested operation is successful. Changes will not be effective until the system is rebooted.
1641:
begin
Result := 1;
end
3010, 0:
begin
Result := 0;
end else // -> case default
begin
Result := -1;
end
end;
end else
begin
//handle failure if necessary; ResultCode contains the error code
Result := -1;
end;
end;
procedure InitializeWizard();
var
frameworkNeeded: Boolean;
installerPath: String;
res: integer;
begin
frameworkNeeded := CheckIfFrameworkNeeded();
if (frameworkNeeded = true)then
begin
if MsgBox('This setup requires the .NET Framework 3.5.'#13 + 'The .NET Framework can be obtained from the web.'#13 + 'Would you like to do this now?', mbConfirmation, MB_YESNO) = IDYES then
begin
// register in the registry the path to your current installer, so it gets called after a reboot
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'MyAppKey', installerPath); // installerPath is the path of your installer
res := Install_NETFramework();
case res of
1: // a restart is going to be executed right away so we abort to avoid the reboot from happening
begin
Abort;
end
0: // a restart is going to be executed later
begin
//Delete the key we added before since we don't need it cause we are installing now
RegDeleteValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'MyAppKey');
// continue with your installation here
end
-1: // an error happened
begin
Abort;
end
end;
end else
begin
//The user has chosen not to install the framework
MsgBox('The application can not be installed unless the framework 3.5 be installed first.', mbError, MB_OK);
Abort;
end;
end else
begin
// the framework is present so continue with your installation here
end;
end;
其中,我认为这个代码可以帮助你解决你的问题。
3
这里是所有的.NET版本和其他软件的完整解决方案: CodeProject
附:我知道这个问题是比较旧的,但这个项目应该是答案的一部分......
[由@jitbit编辑]:也https://github.com/stfx/innodependencyinstaller
相关问题
- 1. 与Inno Setup一起安装时,应用程序无法工作
- 2. Inno Setup - 如何防止安装应用程序时的安装?
- 3. Inno Setup - 用于多个安装程序的安装程序
- 4. 如何使用Inno Setup安装程序升级MSI安装?
- 5. 从Inno Setup一次安装多个应用程序
- 6. 使用Inno Setup创建一个透明的安装程序?
- 7. 用Inno Setup安装Python
- 8. Inno Setup的安装VB6应用程序的DLL
- 9. 用Inno Setup安装程序安装Windows shell扩展DLL
- 10. 检查XML的版本使用Inno Setup的安装程序
- 11. 在Inno Setup安装中运行另一个安装程序
- 12. Inno Setup安装程序测试安装程序退出代码
- 13. 不要使用inno setup安装服务
- 14. Inno Setup - 让Inno安装程序安装程序向主安装程序报告安装进度状态
- 15. 如何使用Inno Setup取消安装程序?
- 16. Inno setup:使用rundll32或dpinst安装驱动程序?
- 17. Inno Setup的指定安装
- 18. 安装在Inno Setup的
- 19. 使用MSI与我的应用程序安装.NET Framework
- 20. Inno Setup:安装程序在安装完成后从不启动
- 21. Inno Setup模块化安装
- 22. 部署c#应用程序 - 用户需要安装.net框架?
- 23. 为其他用户安装Inno Setup
- 24. Inno Setup - 卸载多个应用程序
- 25. 使用Inno安装程序修补Install Shield应用程序
- 26. Inno-Setup问一次安装两次
- 27. Inno Setup的:与CLI标志禁止安装后复选框
- 28. 安装与.NET应用程序
- 29. 使用Inno Setup的
- 30. 安装.NET应用程序
请参见:CodeProject上的文章最新的源代码可以在这里找到: http://stackoverflow.com/q/4334066/588306 – Deanna 2013-01-23 11:59:16
你可能想看到这个问题:[如何安装.NET框架作为使用InnoSetup的先决条件?](http://stackoverflow.com/q/20752882/204690) 这显示了一种方法来测试.Net框架是否已安装,并且如果不安装*,安装其他文件之前安装它,但在用户选择通过向导安装之后安装它。 – Grhm 2014-02-27 16:37:32