如何从[代码]部分中止在/VERYSILENT模式下的Inno Setup安装? [英] How to abort Inno Setup installation in /VERYSILENT mode from [Code] section?
问题描述
我正在尝试从[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';
更清洁的解决方案是在 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屋!