简体   繁体   English

Inno Setup:在安装过程中调用卸载程序 - 这是一种正确的回滚方式吗?

[英]Inno Setup: Calling uninstaller while in setup - is that a proper way to rollback?

I've got a task to sort out a problem with our product installer and eventually came to a dead end with no ideas. 我有一个任务是解决我们的产品安装程序的问题,并最终走到了死胡同,没有任何想法。

The installation process goes like: 安装过程如下:

  1. Install files 安装文件
  2. Configure some services in [Run] section [Run]部分配置一些服务
  3. Run our custom product configurator 运行我们的自定义产品配置程序
  4. If step 3 is successful (configurator returned good exit code) then start those services 如果步骤3成功(配置程序返回了良好的退出代码),则启动这些服务
  5. else rollback installation 其他回滚安装

So the issue was something Shroedinger's - on SOME machines there were unexpected reboot after cancelling install in configurator, without any questions. 所以这个问题是Shroedinger的问题 - 在某些机器上,在配置器中取消安装后出现意外重启,没有任何问题。 Of course that annoyed users. 当然那令人恼火的用户。

I couldn't figure out the criteria by which the machine decided to reboot, but I stumbled onto this thing: 我无法弄清楚机器决定重启的标准,但我偶然发现了这件事:

In [Run] section [Run]部分

Filename: "stub.exe"; Flags: runhidden skipifdoesntexist; BeforeInstall: ConfigureService

Then in [Code] , ConfigureService calls for InstallationAbort proc if configurator returned bad exit code. 然后在[Code] ,如果配置程序返回错误的退出代码,则ConfigureService调用InstallationAbort proc。

Next, in InstallationAbort : 接下来,在InstallationAbort

Exec(ExpandConstant('{uninstallexe}'), '/VERYSILENT /noinstancecheck', '', SW_HIDE,
     ewWaitUntilTerminated, ErrorCode);

So the author calls for uninstaller WHILE IN THE INSTALLER. 因此,作者在安装程序中要求卸载程序。 Using logs I determined, that installation program doesn't end after uninstaller completes work! 使用我确定的日志,安装程序在卸载程序完成工作后不会结束! It's moving to the next step (installation finished)! 它正在进入下一步(安装完成)! After that I can see in log 之后我可以在日志中看到

Restart needed? 需要重启吗? Yes

Note: system never reboots if configurator is not cancelled, ie installation finishes the right way. 注意:如果没有取消配置器,系统永远不会重新启动,即安装完成正确。

So what I tried: 所以我尝试了:

  • Adding /NORESTART to uninstaller Exec call. /NORESTART添加到卸载程序Exec调用。 Doesn't help. 没有帮助。 I think that's because it's installer, who decides to make a restart. 我认为这是因为它是安装程序,谁决定重新启动。
  • Adding WizardForm.CancelButton.OnClick(WizardForm.CancelButton); 添加WizardForm.CancelButton.OnClick(WizardForm.CancelButton); and some other calls to exit setup after call to uninstaller. 调用卸载程序后调用退出设置。 Doesn't help. 没有帮助。
  • Overriding NeedRestart function to return false in case of cancellation 重写NeedRestart函数以在取消时返回false

As I tried to understand, author calls uninstaller because of need to delete installed services (ie call them in UninstallRun with special parameters) 正如我试图理解的那样,作者因为需要删除已安装的服务而调用卸载程序(即使用特殊参数在UninstallRun调用它们)

So, my main question: Is that a normal practice to call uninstaller from code called from [Run] section, to undo changes made in [Run] ? 所以,我的主要问题:从[Run]部分调用的代码调用卸载程序,撤消[Run]更改是否正常?

Is that a normal practice to call uninstaller from code called from [Run] section, to undo changes made in [Run] ? [Run]部分调用的代码调用卸载程序,撤消在[Run]更改是否正常?

In general, it's not a common practice. 一般来说,这不是一种常见的做法。 One should not abort installation in Run section. 不应该在Run部分中止安装。 Inno Setup is not designed to handle that. Inno Setup不是为处理它而设计的。

But if you need to, there's no other way. 但如果你需要,别无他法。 The code you have is most probably based on this: 您拥有的代码很可能基于此:
How to force Inno Setup setup to fail when Run command fails? 当Run命令失败时,如何强制Inno Setup设置失败?

But that does not imply that the installer should require reboot. 但这并不意味着安装程序应该需要重启。 There's some conflict between the installer and uninstaller. 安装程序和卸载程序之间存在一些冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM