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

1.2k views Asked by At

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?

2

There are 2 answers

1
Martin Prikryl On BEST ANSWER

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.

1
Edelcio Molina On

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