仅当在 Inno Setup 中选中其组件时才运行外部驱动程序安装程序

问题描述 投票:0回答:1

我想为我的应用程序创建一个用户友好的安装程序。

其实这是非常基本的:

[Setup]
AppName=My Application
AppVersion=2.5
DefaultDirName={pf}\MyApplication
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}\MyApp.exe
OutputDir=userdocs:MyApp
SetupIconFile=icon.ico
UninstallIconFile=icon.ico

[Components]
Name: "program"; Description: "Program Files"; Types: full compact custom; \
    Flags: fixed
Name: "driver"; Description: "Driver files"; Types: full
Name: "driver\USB"; Description: "USB-Driver"; Types: full; \
     Flags: checkablealone
Name: "driver\MISC"; Description: "MISC-Driver"; Types: full; \
    Flags: checkablealone

[Files]
Source: "*.exe"; DestDir: "{app}"; Components: program
Source: "*.dll"; DestDir: "{app}"; Components: program
Source: "*.bmp"; DestDir: "{app}"; Components: program
Source: "*.ini"; DestDir: "{app}"; Components: program
Source: "USBDriver.exe"; DestDir: "{app}"; Components: driver\usb
Source: "MiscDriver.exe"; DestDir: "{app}"; Components: driver\misc

[Run]
Filename: "{app}\USBDriver.exe"; Description: "Install USB-Driver"; \
    Flags: postinstall skipifdoesntexist
Filename: "{app}\MiscDriver.exe"; Description: "Install Misc-Driver"; \
    Flags: postinstall skipifdoesntexist runascurrentuser

[Icons]
Name: "{commonprograms}\MyApp"; Filename: "{app}\MyApp.exe"
Name: "{commondesktop}\MyApp"; Filename: "{app}\MyApp.exe"

用户应决定是否要安装这两个驱动程序。 为此,我创建了两个

[Run]
部分条目。

安装完成后,应开始安装驱动程序。 事实上,那里有越野车。如果我没有检查驱动程序安装组件或仅检查其中之一,就会遇到问题。尽管如此,安装程序仍然运行我在安装后选择的两个安装文件。

如何只有在用户检查了其组件安装后才开始驱动程序安装?

提前致谢

installation inno-setup
1个回答
2
投票

您必须使用

[Run] 参数
 过滤 
Components
部分条目,与过滤
[Files]
部分中的条目的方式相同:

[Run]
Filename: "{app}\USBDriver.exe"; Description: "Install USB-Driver"; \
    Components: driver\usb; Flags: postinstall
Filename: "{app}\MiscDriver.exe"; Description: "Install Misc-Driver"; \
    Components: driver\misc; Flags: postinstall runascurrentuser

请注意,我已经删除了

skipifdoesntexist
标志,因为我认为这是您解决问题的尝试。一般来说你不应该使用它,因为它的唯一作用是:

如果在

[Run]
部分中指定了此标志,并且 Filename 不存在,安装程序将不会显示
错误消息


如果您想始终运行安装程序,则在安装时,只需删除

postinstall
标志,并将
Description
参数替换为
StatusMsg
参数。

您可能根本不想将安装程序复制到

{app}
。将它们安装到
{tmp}
并使用
deleteafterinstall
标志
让主安装程序在安装后删除它们。

[Files]
Source: "USBDriver.exe"; DestDir: "{tmp}"; Components: driver\usb; \
    Flags: deleteafterinstall
Source: "MiscDriver.exe"; DestDir: "{tmp}"; Components: driver\misc; \
    Flags: deleteafterinstall

[Run]
Filename: "{tmp}\USBDriver.exe"; StatusMsg: "Installing USB-Driver"; \
    Components: driver\usb; Flags: runasoriginaluser
Filename: "{tmp}\MiscDriver.exe"; StatusMsg: "Installing Misc-Driver"; \
    Components: driver\misc

(没有

postinstall
标志,默认为
runascurrentuser
,因此我切换了标志)。

© www.soinside.com 2019 - 2024. All rights reserved.