Posted on January 17, 2021 at 6:30 pm
You can read custom parameters with the {param} constant, example:
if ExpandConstant('{param:Mode|DefaultMode}') = 'DefaultMode' then begin Log('Installing for default mode'); end else begin Log('Installing for different mode'); end; |
It works with syntax like /Name=Value.
And can also be used within sections, such as:
[Registry] Root: HKCU; Subkey: "Software\My Company\My Program\Settings"; ValueType: string; \ ValueName: "Mode"; ValueData: "{param:Mode|DefaultMode}" |
In sections you can also use Check parameter and a custom function:
[Files] Source: "Client.exe"; DestDir: "{app}"; Check: SwitchHasValue('Mode', 'Client') Source: "Server.exe"; DestDir: "{app}"; Check: SwitchHasValue('Mode', 'Server') [Code] function SwitchHasValue(Name: string; Value: string): Boolean; begin Result := CompareText(ExpandConstant('{param:' + Name + '}'), Value) = 0; end; |
If you just want to check if a parameter just exist, use this:
function CmdLineParamExists(const Value: string): Boolean; var I: Integer; begin Result := False; for I := 1 to ParamCount do if CompareText(ParamStr(I), Value) = 0 then begin Result := True; Exit; end; end; |
This function can be used in Pascal scripting [Code] section:
if CmdLineParamExists('/DefaultMode') then begin Log('Installing for default mode'); end else begin Log('Installing for different mode'); end; |
And also in sections:
[Files] Source: "MyProg.hlp"; DestDir: "{app}"; Check: CmdLineParamExists('/InstallHelp') |
Alternatively you may use the GetCmdTail() function:
if Pos('/NOICONS', Uppercase(GetCmdTail())) > 0 then begin Log('Param /NOICONS found'); end; |
References:
https://stackoverflow.com/a/48349992
https://stackoverflow.com/a/14415103
https://jrsoftware.org/ishelp/index.php?topic=isxfunc_comparepackedversion
Updated on February 6, 2021 at 4:22 pm
Other Posts
- Public FTP Server to Test Upload and Download
- How to Parse Command-Line Arguments in Bash
- How to Make Iptables Rules Persistent
- Bash Install Iptables-Persistent Automatically
- Route OpenVPN Connections Through Floating IP
- How to Configure a Floating IP in a VPS (Hetzner)
- Set OpenVPN to Listed on a Specific IP Address
- Bash Trim Leading and Trailing Whitespace from a String
Updated Posts
- Timestamp URLs for SHA1 SHA256 Code Sign 2021
- PHP Multi-cURL to Run Parallel cURL Requests (Example)
- The following signatures were invalid: EXPKEYSIG B188E2B695BD4743
- Best Clean Monospace Web Fonts 2021
- Add New Path to Delphi 10.4 Sydney on Library Path
- AMD Chipsets & Graphics Card Drivers for Windows 7, 8, 10
- AMD Radeon 7400 Drivers for Windows 10
- How to pass custom command-line parameters in InnoSetup