- NSIS Discussion
- Uninstaller does not reboot if run from installer
Archive: Uninstaller does not reboot if run from installer
cowwoc
20th January 2012 20:31 UTC
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
demiller9
20th January 2012 20:56 UTC
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.
cowwoc
20th January 2012 21:09 UTC
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
Anders
20th January 2012 23:02 UTC
The installer is blocking the reboot IIRC, I think there is a plugin that prevents it from doing that...
cowwoc
23rd January 2012 17:44 UTC
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?
cowwoc
23rd January 2012 20:13 UTC
Excellent. Thanks Stu! :)
Gili
cowwoc
23rd January 2012 21:01 UTC
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
cowwoc
23rd January 2012 21:10 UTC
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?
Afrow UK
23rd January 2012 21:12 UTC
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
cowwoc
23rd January 2012 21:16 UTC
I stand corrected. I'm getting error code 0 (not 164) whether it reboots or not.
cowwoc
23rd January 2012 21:17 UTC
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.
Afrow UK
23rd January 2012 21:20 UTC
IfRebootFlag 0 +2
SetErrorLevel 99
Stu
cowwoc
23rd January 2012 21:56 UTC
Originally posted by Afrow UK
IfRebootFlag 0 +2
SetErrorLevel 99
Stu
I added this to the end of:
Section "Uninstall"
Thanks again,
Gili