2

I am using this code in my custom UninstallProgressForm (Custom Uninstall page (not MsgBox)) to define a message after the uninstall (that does not have the original uninstaller messages):

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;

I want to hide this message at determinate moment, at uninstall my previous version (if is present). For uninstall my previous version i am using this code: How to detect old installation and offer removal?. I have modified the code of the previous link with this code to run the uninstaller if there is a previous version: Executing UninstallString in Inno Setup

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Nico Z
  • 997
  • 10
  • 33

1 Answers1

2

Add a custom switch to the uninstaller, when you execute it to uninstall the previous version. Like /UPDATE:

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

And then check for the switch:

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;

The CmdLineParamExists function comes from Passing conditional parameter in Inno Setup.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992