After creating my setup.exe I have to pack it for various software deployment tools. Therefore I can't call the setup.exe with parameters, instead I have placed my own parameters in a setup.ini file next to the setup.exe
[Code]
var
MyIniFile: String;
function InitializeSetup(): Boolean;
var
LoadFromIniFile: String;
begin
Result := true;
MyIniFile := ExpandConstant('{srcexe}'); //writes the full path of the setup.exe in "MyIniFile"
MyIniFile := Copy(MyIniFile, 1, Length(MyIniFile) - Length(ExtractFileExt(MyIniFile))) + '.ini'; //changes the ".exe" into ".ini"
if FileExists(MyIniFile) then LoadFromIniFile := MyIniFile; //checks wether there is a ini-file
if LoadFromIniFile <> '' then begin
MyLogFile := GetIniString('Setup', 'Log', MyLogFile , LoadFromIniFile);
ProductName := GetIniString('Setup', 'ProductName', ProductName, LoadFromIniFile);
end;
end;
Now I want to also place the so called "Setup Command Line Parameters" (listed on the Inno Setup Help site) in my ini-file. I think that there is a way for the /Dir="x:\dirname
parameter, which I did not figure out yet. But I also want to have the /SILENT
parameter in there, do you think there is a way to do this? If yes, how would you do this? If not, can you please give me a hint why not?
So customize your installer for different products, I'd recommend you to use a pre-processor and automatically build the installer for each product (with different "defines"), instead of using an external INI file.
For example to be able to change application name and resulting executable when building the installer, use a script like:
Now you can create two different installers automatically using command-line:
Regarding the implicit silent installation:
There's no API other than the command-line
/SILENT
switch to trigger silent installation.But you can create a near-silent installation by disabling most installer pages:
Actually the above example disables all default pages. But Inno Setup compiler will ignore the
DisableReadyPage=true
, if all other previous pages are disabled.You may want to choose a different page to show instead. For example a Welcome page (by omitting
DisableWelcomePage=true
, but keeping theDisableReadyPage=true
).If you do not mind about using external files (as you already use an external INI file), you can of course wrap the installer to a batch file and call the installer with the
/SILENT
switch.