The correct way to start the installation in silent mode is to always execute it using the /SILENT command line switch. For example, as follows:
setup.exe /SILENT
After we clarified your requirement in the comments, I see that you really want to create an installation that will work in silent mode without the mentioned command line parameter. There is currently no built-in way to tell the compiler that you want to create a silent configuration, so we need to get around this by restarting the installation with /SILENT when the configuration is initialized.
The following script shows this workaround:
[Setup] AppName=My Program AppVersion=1.5 DefaultDirName={pf}\My Program [Code] #ifdef UNICODE #define AW "W" #else #define AW "A" #endif type HINSTANCE = THandle; function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string; lpParameters: string; lpDirectory: string; nShowCmd: Integer): HINSTANCE; external 'ShellExecute{#AW}@shell32.dll stdcall'; function InitializeSetup: Boolean; begin // if this instance of the setup is not silent which is by running // setup binary without /SILENT parameter, stop the initialization Result := WizardSilent; // if this instance is not silent, then... if not Result then begin // re-run the setup with /SILENT parameter; because executing of // the setup loader is not possible with ShellExec function, we // need to use a WinAPI workaround if ShellExecute(0, '', ExpandConstant('{srcexe}'), '/SILENT', '', SW_SHOW) <= 32 then // if re-running this setup to silent mode failed, let allow // this non-silent setup to be run Result := True; end; end;
TLama
source share