Inno Setup - 检测何时(un)安装程序由另一个进程自动运行以执行特定任务

时间:2017-11-02 15:23:56

标签: inno-setup

我在自定义UninstallProgressFormCustom Uninstall page (not MsgBox))中使用此代码在卸载后定义消息(没有原始卸载程序消息):

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  case CurUninstallStep of
    usPostUninstall:
      if not WizardVerySilent and UninstallSilent then begin
        MsgBox(CustomMessage('UninstallComplete'), mbInformation, MB_OK);
      end;
  end;
end;

我想在确定的时刻隐藏此消息,在卸载我之前的版本(如果存在)。对于卸载我以前的版本,我使用此代码:How to detect old installation and offer removal?。我已使用此代码修改了上一个链接的代码,以便在以前的版本中运行卸载程序:Executing UninstallString in Inno Setup

1 个答案:

答案 0 :(得分:2)

在执行卸载以卸载先前版本时,将自定义开关添加到卸载程序。像/UPDATE

Exec(UninstallPath, UninstallParams + ' /UPDATE', '', SW_SHOW,
     wWaitUntilTerminated, iResultCode)

然后检查开关:

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  case CurUninstallStep of
    usPostUninstall:
      if UninstallSilent and (not WizardVerySilent) and 
         (not CmdLineParamExists('/UPDATE')) then
      begin
        MsgBox(CustomMessage('UninstallComplete'), mbInformation, MB_OK);
      end;
  end;
end;

CmdLineParamExists功能来自Passing conditional parameter in Inno Setup