Archive: Uninstaller does not reboot if run from installer


Uninstaller does not reboot if run from installer
My installer code runs the uninstaller (in .onInit) if it detects the software is already installed. Once the software finishes uninstalling, it continues with the installation.

I am using "Delete /REBOOTOK" to delete files in my uninstaller. If one of the files cannot be deleted, it asks the user to reboot the system.

1. If I intentionally lock a file, run the uninstaller directly, and the user agrees to reboot the system *does* reboot.

2. If I do the same, but launch the uninstaller from inside the installer, it does *not* reboot.

The installer is invoking the uninstaller using this code:

ExecWait '$0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file


Why isn't the uninstaller rebooting?

Thanks,
Gili

Windows 'knows' that the installer is running and prevents the reboot. I had a similar problem and solved it by making the uninstaller terminate the installer.


Originally posted by demiller9
Windows 'knows' that the installer is running and prevents the reboot. I had a similar problem and solved it by making the uninstaller terminate the installer.
Seems hackish, but just in case... how do you do that? :)
Is there a cleaner solution?

Thanks,
Gili

The installer is blocking the reboot IIRC, I think there is a plugin that prevents it from doing that...


Originally posted by Anders
The installer is blocking the reboot IIRC, I think there is a plugin that prevents it from doing that...
Where can I find this plugin?

http://nsis.sourceforge.net/ShutdownAllow_plug-in

Stu


Excellent. Thanks Stu! :)

Gili


Okay, now I've got one more problem... The uninstaller is causing the system to reboot, but in the meantime it returns control back to the installer which allows the user to begin installation.

I noticed that the uninstaller is returning exit code 164 (or -164, I forget). Where does this number come from? Is it documented somewhere? Can I rely on it not changing?

Thanks,
Gili


Hmm, it seems I jumped the gun. I get an exit code of 164 whether the uninstaller reboots or not. Any ideas on how to tell the installer to abort when the uninstaller tries to reboot?


Looking at the source it just returns the current error level (SetErrorLevel) so perhaps something in your script is setting it to 164. You can try setting your own error level just before rebooting.

Stu


I stand corrected. I'm getting error code 0 (not 164) whether it reboots or not.


Stu,

Which function gets executed if the user chooses to reboot (I'd like to SetErrorLevel there)? I believe the reboot flag is being set by "Delete /REBOOTOK". I never explicitly set it.


IfRebootFlag 0 +2
SetErrorLevel 99
Stu

Originally posted by Afrow UK
IfRebootFlag 0 +2
SetErrorLevel 99
Stu
I added this to the end of:

Section "Uninstall"

Thanks again,
Gili