我想为我的应用程序创建一个用户友好的安装程序安装程序。
实际上它非常基本:
[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]
部分条目。
安装完成后,应开始安装驱动程序。 实际上那里有马车。如果我检查没有驱动程序安装组件,或者只检查其中一个,我遇到了问题。然而,安装程序仍然运行我在安装后选择的两个安装文件。
如果用户选中其组件进行安装,我怎么能启动驱动程序安装?
提前致谢
答案 0 :(得分:1)
您必须使用the Components
parameter过滤[Run]
部分条目,就像过滤[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
不存在的情况下,安装程序不会显示错误消息。
如果您想要始终运行安装程序,请在安装后立即删除the postinstall
flag并将Description
参数替换为StatusMsg
参数。
您可能根本不想将安装程序复制到{app}
。将它们安装到{tmp}
并使用the deleteafterinstall
flag让主安装程序在安装后将其删除。
[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
,因此我切换了标志。