Anand
Anand

Reputation: 493

How to exit from installation in silent mode based on a check after InitializeSetup

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

Answers (1)

Martin Prikryl
Martin Prikryl

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:

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

Related Questions