Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
873 views
in Technique[技术] by (71.8m points)

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

Using innosetup and want to show error/msgbox if one of the [RUN] process does not return process code 0. I'm using it for authorization process, if authorization is not successful, i want to notify the user.

I have following:

Filename: "{pf32}Common FilesAuthorization.exe"; Parameters: " "{code:GetAuthorizationFilePath}" /s"; WorkingDir: "{tmp}"; Flags: skipifdoesntexist hidewizard; StatusMsg: "Authorizing License"; 

Returns me:

Process exit code:0

0 of course is successful, but if its not 0 i want to notify the user.

Is there a way to do that?

Thanks and Regards, Kev84

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 FilesAuthorization.exe'), '', '', 
      SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      if ResultCode = 0 then    
        Result := True
      else
        MsgBox('The authorization failed!', mbCriticalError, MB_OK);
    end;
  end;
end;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...