1
votes

I've got a task to sort out a problem with our product installer and eventually came to a dead end with no ideas.

The installation process goes like:

  1. Install files
  2. Configure some services in [Run] section
  3. Run our custom product configurator
  4. If step 3 is successful (configurator returned good exit code) then start those services
  5. else rollback installation

So the issue was something Shroedinger's - on SOME machines there were unexpected reboot after cancelling install in configurator, without any questions. Of course that annoyed users.

I couldn't figure out the criteria by which the machine decided to reboot, but I stumbled onto this thing:

In [Run] section

Filename: "stub.exe"; Flags: runhidden skipifdoesntexist; BeforeInstall: ConfigureService

Then in [Code], ConfigureService calls for InstallationAbort proc if configurator returned bad exit code.

Next, in InstallationAbort:

Exec(ExpandConstant('{uninstallexe}'), '/VERYSILENT /noinstancecheck', '', SW_HIDE,
     ewWaitUntilTerminated, ErrorCode);

So the author calls for uninstaller WHILE IN THE INSTALLER. Using logs I determined, that installation program doesn't end after uninstaller completes work! It's moving to the next step (installation finished)! After that I can see in log

Restart needed? Yes

Note: system never reboots if configurator is not cancelled, i.e installation finishes the right way.

So what I tried:

  • Adding /NORESTART to uninstaller Exec call. Doesn't help. I think that's because it's installer, who decides to make a restart.
  • Adding WizardForm.CancelButton.OnClick(WizardForm.CancelButton); and some other calls to exit setup after call to uninstaller. Doesn't help.
  • Overriding NeedRestart function to return false in case of cancellation

As I tried to understand, author calls uninstaller because of need to delete installed services (i.e. call them in UninstallRun with special parameters)

So, my main question: Is that a normal practice to call uninstaller from code called from [Run] section, to undo changes made in [Run]?

1
Show us a full installer and uninstaller log.Martin Prikryl

1 Answers

1
votes

Is that a normal practice to call uninstaller from code called from [Run] section, to undo changes made in [Run]?

In general, it's not a common practice. One should not abort installation in Run section. Inno Setup is not designed to handle that.

But if you need to, there's no other way. The code you have is most probably based on this:
How to force Inno Setup setup to fail when Run command fails?

But that does not imply that the installer should require reboot. There's some conflict between the installer and uninstaller.