Reputation: 493
I am trying to do something similar to this.
This works in UI mode - installer exits. However, in /Silent mode, it shows the message box but goes ahead after clicking the Ok button.
Can you please suggest how to achieve similar functionality in silent mode (i.e. gracefully exit the setup)
Upvotes: 1
Views: 805
Reputation: 202222
There's no difference in a the silent mode for implementing prerequisites check. Just test your prerequisites in the InitializeSetup
event function, and return False
, if you want to stop the installation.
The only things to consider for silent installations are:
SuppressibleMsgBox
function for error messages, instead of the plain MsgBox
. This way the message can be suppressed with the /suppressmsgboxes
command-line switch./verysilent
).function WizardVerySilent: Boolean;
var
i: Integer;
begin
Result := False;
for i := 1 to ParamCount do
if CompareText(ParamStr(i), '/verysilent') = 0 then
begin
Result := True;
Break;
end;
end;
function InitializeSetup(): Boolean;
var
Message: string;
begin
Result := True;
if IsDowngrade then
begin
Message := 'Downgrade detected, aborting installation';
if not WizardVerySilent then
begin
SuppressibleMsgBox(Message, mbError, MB_OK, IDOK);
end
else
begin
Log(Message);
end;
Result := False;
end;
end;
Upvotes: 2