I want to create an user-friendly setup installer for my application.
Actually it's very basic:
[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"
The user should decide if he wants to install the both drivers.
For that I created the two [Run]
section entries.
After the installation, the driver installation should start. Actually it's buggy there. I got a problem if I checked no driver installation component, or just one of them. Nevertheless the installer still runs both setup files I got to choose after installation.
How could I start the driver installation only if the user checked its component for installation?
Thanks in advance
You have to filter the [Run]
section entries using the Components
parameter, the same way you filter the entries in the [Files]
section already:
[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
Note that I've removed the skipifdoesntexist
flag as I suppose it was your attempt to solve the problem. In general you should not use it, as its only effect is:
If this flag is specified in the
[Run]
section, Setup won't display an error message ifFilename
doesn't exist.
If you want to run the installers always, when they are installed, just remove the postinstall
flag and replace the Description
parameter with the StatusMsg
parameter.
You also probably do not want to copy the installers to the {app}
at all. Install them to the {tmp}
and use the deleteafterinstall
flag to have the main installer remove them after the installation.
[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
(Without the postinstall
flag, the default is the runascurrentuser
, hence I switched the flags).