如何从[代码]部分中止在/VERYSILENT模式下的Inno Setup安装? [英] How to abort Inno Setup installation in /VERYSILENT mode from [Code] section?

查看:356
本文介绍了如何从[代码]部分中止在/VERYSILENT模式下的Inno Setup安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从[Code]部分(在AfterInstall处理程序中)启动某个Windows服务.如果无法启动,我想回滚安装.

I'm trying to start a certain Windows service from [Code] section (in AfterInstall handler). When it fails to start I'd like to rollback installation.

通常从UI运行安装程序时,WizardForm.Close()会正确执行工作.但是,当使用/verysilent命令行参数执行安装程序时,似乎会忽略WizardForm.Close并继续进行安装. 我还尝试了Abort(),这是其他有关Stack Overflow的文章所建议的,但它的作用与任何其他preventiblemsgbox一样,并且不会中断安装.

Typically when setup is ran from UI, WizardForm.Close() does the job right. But when installer is executed with /verysilent command line parameter, WizardForm.Close seems to be ignored and installation goes on. I also tried Abort(), suggested by other article on Stack Overflow, but it works just like any other suppressiblemsgbox and doesn't break the installation.

有什么方法可以有条件地以/verysilent模式中止安装吗?

Is there any way to conditionally abort installation in /verysilent mode?

推荐答案

无法以编程方式触发回滚.

There's no way to trigger rollback programmatically.

您所能做的就是使用 ExitProcess WinAPI函数.

All you can do is to forcefully abort the installation using the ExitProcess WinAPI function.

procedure ExitProcess(exitCode:integer);
  external 'ExitProcess@kernel32.dll stdcall';

信用:从[代码]的Inno Setup安装退出..

更清洁的解决方案是在 CurStepChanged(ssInstall) .如果出现问题,请使用 Abort函数中断安装. .在这种情况下,Abort起作用.请参见功能文档.

A cleaner solution would be to install the file and start the Windows service programmatically at the beginning of the CurStepChanged(ssInstall). And use the Abort function to interrupt the installation, if something goes wrong. In this context the Abort works. See the function documentation.

这篇关于如何从[代码]部分中止在/VERYSILENT模式下的Inno Setup安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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