如何根据 InitializeSetup 后的检查以静默模式退出安装

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

我正在尝试做类似于 this 的事情。

这适用于 UI 模式 - 安装程序退出。但是,在 /Silent 模式下,它显示消息框,但在单击“确定”按钮后继续。

能否请您建议如何在静默模式下实现类似的功能(即优雅地退出设置)

执行先决条件检查的静默模式没有区别。如果您想停止安装,只需在 InitializeSetup event function 和 return False 中测试您的先决条件。

静默安装唯一需要考虑的事情是:

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;