How to abort Inno Setup installation in /VERYSILENT mode from [Code] section?
Asked Answered
A

2

2

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.

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.

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

Ander answered 21/12, 2016 at 10:31 Comment(0)
E
2

There's no way to trigger rollback programmatically.

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

procedure ExitProcess(exitCode:integer);
  external '[email protected] stdcall';

Credits: Exit from Inno Setup Installation from [code].


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.

Exospore answered 22/12, 2016 at 11:52 Comment(1)
Unfortunately I can't use Abort() because installer first installs service DLLs and then uses the service to publish files, which are installed next. But ExitProcess() works like a charm. Thanks!Ander
C
-1

WizardForm.Show(); //forcing to show even with verysilent

Clarendon answered 15/3, 2017 at 2:21 Comment(1)
How does this answer the question?Exospore

© 2022 - 2024 — McMap. All rights reserved.