Install files if the command line switch is passed to the installer based on Inno Setup

I want to know if there is a way to add some command-line options to the Inno Setup-based installer for the /VERYSILENT mode if, for example, I have theses:

 Source: "{app}\Portable-File.exe"; DestDir: "{app}"; MinVersion: 0.0,5.0; Check: install1; Source: "{app}\Installer-File.exe"; DestDir: "{app}"; MinVersion: 0.0,5.0; Check: porta1; 

And I have these lines based on my two validation examples:

 "MyProgram.exe" /VERYSILENT /install1 /EN "MyProgram.exe" /VERYSILENT /porta1 /EN 
+1
source share
1 answer

Implement the install1 and porta1 , such as:

 function HasCommandLineSwitch(Name: string): Boolean; var I: Integer; begin Result := False; for I := 1 to ParamCount do begin if CompareText(ParamStr(I), '/' + Name) = 0 then begin Result := True; Break; end; end; end; function install1: Boolean; begin Result := HasCommandLineSwitch('install1'); end; function porta1: Boolean; begin Result := HasCommandLineSwitch('porta1'); end; 

In fact, you can use HasCommandLineSwitch directly in the Check parameter:

 [Files] Source: "Portable-File.exe"; DestDir: "{app}"; Check: HasCommandLineSwitch('install1') Source: "Installer-File.exe"; DestDir: "{app}"; Check: HasCommandLineSwitch('porta1') 

Although I assume that your install1 and porta1 function will actually do more than just call HasCommandLineSwitch , so this is probably not applicable to you.


In fact, since I know that you have flags corresponding to install1 and porta1 , what you really want to do is check these flags when the installer starts, if the specified parameters are specified. Thus, you can use /install1 and /porta1 to set the default values, even if they are not used in conjunction with /verysilent . And it will still work even in /verysilent more, even if the user never sees the checkboxes (they are still present, although they are not displayed)

 install1 := TNewRadioButton.Create(WizardForm); install1.Checked := HasCommandLineSwitch('install1'); porta1 := TNewRadioButton.Create(WizardForm); porta1.Checked := HasCommandLineSwitch('porta1'); 

And you save the install1 and porta1 function to return the state of the checkboxes, as shown in the Inno Setup Set Uninstallable directive based on a custom checkbox. .

+1
source

Source: https://habr.com/ru/post/974816/


All Articles