Archive: Return code of uninstaller


Return code of uninstaller
Hi!
I want to understand when my installer has found a previous version and has run it's uninstaller, if the user hit the Cancel button in the uninstaller so the current installer to be stopped too. Is there a way to find if the user hit Cancel from the return value?


From the NSIS Users Manual (Appendix D - Useful Information):

Error levels:

Like other applications installers made by NSIS return error levels as a result of their execution. Checking the error level can be useful if you call an NSIS installer from another application or installer.

0 - Normal execution (no error)
1 - Installation aborted by user (cancel button)
2 - Installation aborted by script

To find out how to access the uninstaller's error level, read the rest of this section of the manual:
http://nsis.sourceforge.net/Docs/AppendixD.html#D.2


Thank You!
It's interesting that in the manual is written that the uninstaller copies itself into the $TEMP folder and executes from there so to be able to get the correct return code you should copy it there manually. But I experimented and saw that even if I don't copy it by myself I still get the correct codes. Does anybody know something about this?


As of NSIS 2.01, you can set the error level to other values using SetErrorLevel.

If you execute the uninstaller with _?= it will not copy itself and you'll get the real return value.