Search code examples
inno-setuppascalscript

Inno Setup Log setup exit code


The Inno Setup log file does not, by default, include the setup exit code. I am looking for a way to include this in the log file. I am assuming this would be done using the Log function and including it in the DeinitializeSetup event. Something like this:

procedure DeinitializeSetup();
begin
  Log('Exit code: ' + ExitCode);
end;

What I don't know, and cannot seem to find, is how to return the setup exit code, so that I can use it in the Log function. Is this the best way to do this and how do I return the setup exit code?


Solution

  • There's no way to retrieve the exit code in Pascal Script.

    All you can do is to log, if installation was successful or not (what is logged anyway already).

    One way to do that is by checking, if the GetCustomSetupExitCode event function was called or not (it's called when exit code would be 0 only).

    var
      ZeroExitCode: Boolean;
    
    function GetCustomSetupExitCode: Integer;
    begin
      ZeroExitCode := True;
      Result := 0;
    end;
    
    procedure DeinitializeSetup();
    begin
      if ZeroExitCode then
        Log('Zero exit code')
      else
        Log('Non-zero exit code');
    end;