I want to run the Innosetup installer completely silently, but the tool that will execute my installer has a fixed set of arguments (meant for a different installer technology). This threads answer is great:
[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's allow
// this non-silent setup to be run
Result := True;
end;
end;
Is there a way to wait for this process to finish?
I want to run the Innosetup installer completely silently, but the tool that will execute my installer has a fixed set of arguments (meant for a different installer technology). This threads answer is great:
[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's allow
// this non-silent setup to be run
Result := True;
end;
end;
Is there a way to wait for this process to finish?
Share Improve this question asked Feb 17 at 12:11 audevaudev 312 bronze badges 3 |1 Answer
Reset to default 0Run the process with ShellExecuteEx
and wait for it to finish using WaitForSingleObject
.
For a complete code, see:
Create a button on Inno Setup custom wizard page to interrupt an program executed from the installer
/SILENT
, presenting it like the only problem with it is "to wait for this process to finish". – Martin Prikryl Commented Feb 17 at 14:21