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:
- Install files
- Configure some services in
[Run]
section - Run our custom product configurator
- If step 3 is successful (configurator returned good exit code) then start those services
- 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 uninstallerExec
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]
?