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?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Piotr Maj
  • 63
  • 6

2 Answers2

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 'ExitProcess@kernel32.dll 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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 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! – Piotr Maj Dec 22 '16 at 15:21
-1

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