Using Process Exit code to show error message for a specific File in [Run]

I think there’s no way to accomplish this from the [Run] section. What you can do is:

  • use the Pascal Script for this task
  • or display the modal error message from your executed application Authorization.exe and terminate it only after the user confirms the error message (setup will then continue e.g. with the execution of the other files in the [Run] section)

Here is the code sample of the Pascal Script; you can check also the commented version of this code:

[Code]

function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
begin
  Result := True;

  if CurPageID = wpWelcome then
  begin
    Result := False;
    if Exec(ExpandConstant('{pf32}\Common Files\Authorization.exe'), '', '', 
      SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      if ResultCode = 0 then    
        Result := True
      else
        MsgBox('The authorization failed!', mbCriticalError, MB_OK);
    end;
  end;
end;

Leave a Comment