How to call an exe when Inno Setup installation fails (within the installer itself)?

匆匆过客 提交于 2020-02-28 11:01:06

问题


I've been using Inno Setup for several months now, but I'm struggling to find how to detect, from within the installer itself, an error that would cause Inno Setup to end with a non-zero exit code.

I've thought about using CurStepChanged with the ssDone step, or even DeinitializeSetup, but I can't find how to get access to the wizard's exit-code.

Did I miss something? There must be a way to do it...


回答1:


You cannot find out installer exit code from the Pascal Scripting.


If you want to detect that the installer failed, remember if CurStepChanged was called with ssDone and test that in DeinitializeSetup.

var
  Succeeded: Boolean;

procedure DeinitializeSetup();
begin
  if Succeeded then
  begin
    Log('Installation succeeded');
  end
    else
  begin
    Log('Installation failed');
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssDone then
  begin
    Succeeded := True;
  end;
end;

There are edge cases, when ssDone is used even, if the installer fails.

For example, when it fails because a machine was not restarted to complete the previous installation. In this case the CurStepChanged is not called with ssPostInstall. So you may want to check for both steps, if this scenario can happen in your installer.



来源:https://stackoverflow.com/questions/33343283/how-to-call-an-exe-when-inno-setup-installation-fails-within-the-installer-itse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!