0
votes

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?

1
Do you want to run the current setup with the parameters stored in the INI file ? Or another setup packed inside the current one ?TLama
@TLama I want to run the current setup with the parameters in the INI file, at least that was, what I was thinking of while asking the question. But actually both is true, so yes there is also another setup called to which I would love to pass one parameter.Viki Stepinfaith

1 Answers

0
votes

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:

[Setup]
AppName={#AppName}
OutputBaseFilename={#BaseFilename}

Now you can create two different installers automatically using command-line:

ISCC.exe Example1.iss /dAppName=App1 /dBaseFilename=SetupApp1
ISCC.exe Example1.iss /dAppName=App2 /dBaseFilename=SetupApp2

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:

[Setup]
DisableWelcomePage=true
DisableDirPage=true
DisableProgramGroupPage=true
DisableReadyPage=true
DisableFinishedPage=true

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 the DisableReadyPage=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.