Inno Setup在安装过程中启动可执行文件(用于安装驱动程序) [英] Inno Setup launch executable (to install drivers) during installation

查看:461
本文介绍了Inno Setup在安装过程中启动可执行文件(用于安装驱动程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Inno Setup为我的应用程序创建安装程序.该安装程序非常基础,仅复制一些文件.效果很好,对此我感到满意.

I am using Inno Setup to create an installer for my application. The installer is very basic and just copies some files. This works very well and I am happy with it.

我最近实现了USB支持,为此需要从IVI Foundation安装USB驱动程序.它基本上是一个exe文件,必须在安装过程中的某个位置启动.直到现在,用户还必须单独安装驱动程序,这还不算很优雅.我的第一种方法是:

I recently implemented USB support and need to install the USB driver from the IVI foundation for that. It is basically an exe file that has to be launched somewhere during the setup process. Until now, the user has to install the drivers separately, which is not so elegant. My first approach was this:

[Run]
Filename: "{app}\driver\IviSharedComponents_2.2.1.exe"; Description: "Install USB driver (IVI Foundation)"; Flags: postinstall skipifsilent
Filename: "{app}\driver\IviSharedComponents64_2.2.1.exe"; Description: "Install 64bit USB driver (IVI Foundation)"; Flags: postinstall skipifsilent
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: postinstall skipifsilent

这有效,但是用户必须选择正确的位数.这样做的好处是,他可以选择不安装它(在这种情况下,应用程序将忽略USB功能,这很好).我真正想要的是自动检测系统的位并运行设置过程. 不必在[Run]部分中,尽管我对此没有任何反对(因为用户可以选择不安装它).

This works, but the user has to select the correct bitness. The advantage here is that he can choose not to install it (in which case the application just ignores the USB functionality which is fine). What I actually want is to detect the bitness of the system automatically and run the setup process. This does not have to be in the [Run] section, although I would not have anything against it (because the user can choose not to install it).

我还找到了一些代码,并试图像这样运行它:

I also found some code and tried to run it like this:

[Code]
procedure CurStepChanged (CurStep: TSetupStep);
var
   WorkingDir:   String;
   ReturnCode:   Integer;
begin    
   if (ssInstall = CurStep) then
     Log('Starting driver installation');
     WorkingDir := ExpandConstant ('{app}\driver');
     Exec ('IviSharedComponents_2.2.1.exe', '', WorkingDir, SW_SHOW, ewWaitUntilTerminated, ReturnCode);
end;

但这不会启动安装(尽管我可以看到日志条目正在启动驱动程序安装").我的路线有问题吗?我在做什么错?如何更改此脚本以根据位数自动选择正确的可执行文件?

But this does not start the installation (although I can see the log entry 'Starting driver installation'). Is there something wrong with my path? What am I doing wrong and how could I change this script to automatically select the right executable depending on the bitness?

我将建议的解决方案与[Tasks]条目一起使用.实现看起来像这样(仅供参考):

I used the proposed solution with the [Tasks] entry. The implementation looks like this (just for reference):

[Tasks]
Name: "install_usb"; Description: "Install USB drivers (IVI Foundation)"; GroupDescription: "External drivers:";

[Run]
Filename: "{app}\driver\IviSharedComponents_2.2.1.exe"; StatusMsg: "Installing USB driver (IVI Foundation)"; Check: Not IsWin64(); Tasks: install_usb; Flags: skipifsilent
Filename: "{app}\driver\IviSharedComponents64_2.2.1.exe"; StatusMsg: "Installing USB driver (IVI Foundation)"; Check: IsWin64(); Tasks: install_usb; Flags: skipifsilent

效果很好,非常感谢您的帮助!

This works very well, thanks a lot for your help!

推荐答案

在这种情况下,最好删除postinstall标志,以便它在设置过程结束时(但在完成之前)无条件运行,并添加Check:参数以将其限制为正确的位数:

In this case, it's best to remove the postinstall flag so it runs unconditionally at the end of the setup process (but before it says finished) and add a Check: parameter to limit it to the correct bitness:

[Run]
Filename: "{app}\driver\IviSharedComponents_2.2.1.exe"; StatusMsg: "Installing USB driver (IVI Foundation)"; Check: Not IsWin64(); Flags: skipifsilent
Filename: "{app}\driver\IviSharedComponents64_2.2.1.exe"; StatusMsg: "Installing USB driver (IVI Foundation)"; Check: IsWin64(); Flags: skipifsilent

如果希望这是有条件的,则可以使用普通的[Tasks]条目,该条目会在安装开始之前提示.

If you want this to be conditional, you can use a normal [Tasks] entry that prompts before the setup starts.

这篇关于Inno Setup在安装过程中启动可执行文件(用于安装驱动程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆