当Inno Setup安装失败时(在安装程序本身内),如何调用exe? [英] How to call an exe when Inno Setup installation fails (within the installer itself)?

查看:187
本文介绍了当Inno Setup安装失败时(在安装程序本身内),如何调用exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Inno Setup几个月了,但是我一直在努力寻找如何从安装程序本身内部检测导致Inno Setup以非零退出代码结束的错误. /p>

我曾经考虑过将CurStepChangedssDone甚至是DeinitializeSetup一起使用,但是我找不到如何访问向导的退出代码.

我错过了什么吗?一定有办法做到这一点...

解决方案

您无法从Pascal脚本中找到安装程序退出代码.


如果要检测安装程序失败,请记住是否用ssDone调用了CurStepChanged并在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;
 


在某些情况下,即使安装程序失败也使用ssDone.

例如,当由于未重新启动计算机而无法完成先前的安装而导致失败时.在这种情况下,CurStepChanged不会与ssPostInstall一起调用.因此,如果这种情况在安装程序中可能发生,您可能要检查两个步骤.

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...

解决方案

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.

这篇关于当Inno Setup安装失败时(在安装程序本身内),如何调用exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆