1

I am trying to do something similar to this.

  • Do a version check after Welcome page is displayed
  • Display a message box (with mbInformation, MB_OK) in case of downgrade and exit

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)

Community
  • 1
  • 1
Anand
  • 473
  • 3
  • 14

1 Answers1

2

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;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992