问题
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