Skip to content
⌘ NSIS Forum Archive

return values from the uninstaller

7 posts

coco_vc#

return values from the uninstaller

Hi all,

In case my product is already installed, I run from my installer first the uninstaller and then if this one finishes successfully I continue then with the installation.

So, I need to check if the uninstaller finished successfully. For this I'm doing the following:

...
ReadRegStr $UninstString ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
HideWindow
ClearErrors
ExecWait '$UninstString _?=$INSTDIR'
IfErrors 0 uninstallDone1_ReinstallValidateSelection
GetErrorLevel $0 ; check the return error value from the uninstaller
MessageBox MB_ICONEXCLAMATION|MB_OK "ERROR in uninstaller: $0"
...
Questions:
1) If there is failure I always see in my msgbox that the uninstaller returned -1, even if in the uninstaller I do before quiting

SetErrorLevel 2
Why do I always see the $0 being -1?
2) In help in "D.1 Error Levels" is written: "1 - Installation aborted by user (cancel button)". But with the procedure above what I notice is that regardless from what page I chose cancel (default NSIS page, or custom page) the value showed in the msgbox is always -1. Why is that?
3) If I quit the uninstaller in a custom page function the return value is success, but if I quit from the uninstall section I get failure (-1). Why the different behaviour when Quit is called in the uninstall section and in the custom-pages-functions?
4) In help in "4.9.1.1 Delete" is written: "The error flag is set if files are found and cannot be deleted.". But I tried that by doing in the uninstaller:

Delete /REBOOTOK "$INSTDIR\momo.exe"
and momo.exe was in use while running the setup and with the very above code (msgbox) I get success, so the uninstaller didn't return error, even though the file was not deleted b/c was in use. Why diff behaviour than what's written in help?

Thx,
Viv
Afrow UK#
You should check the exit code of the uninstaller with:
ExecWait '$UninstString _?=$INSTDIR' $R0

$R0 will now contain the exit code.

Execute the specified program and wait for the executed process to quit. See Exec for more information. If no output variable is specified ExecWait sets the error flag if the program executed returns a nonzero error code, or if there is an error. If an output variable is specified, ExecWait sets the variable with the exit code (and only sets the error flag if an error occurs; if an error occurs the contents of the user variable are undefined).
-Stu
coco_vc#
Ahh, thx for the tip! Nevertheless this would explain only the problem 1 and 2, but not the 3 and 4 I described in my first entry, right?

Thx,
Viv
Afrow UK#
3) The installer hasn't failed if you Quit on a page, because you haven't installed anything yet. Surely that makes sense?

4) What does IfErrors show?

-Stu
coco_vc#
3) The installer hasn't failed if you Quit on a page, because you haven't installed anything yet. Surely that makes sense?
No, what I ment is: in the UNinstaller I have somewhere a custom page. If in the function of this custom page I call Quit, the return value of the whole uninstaller is success. But if I call Quit in the Section Uninstall, the return value of the whole uninstaller is -1.
In both cases I'm already in the uninstall procedure so I don't understand why different results.


4) What does IfErrors show?
no errors, which is different than what's written in the help. Seems Comperio got to the same result in: http://forums.winamp.com/showthread....76#post1984276

Thx,
Viv
Afrow UK#
3) No. You aren't uninstalling until you reach the UninstFiles page.

4) This could be a bug. On the NSIS project page (http://www.sf.net/projects/nsis) please post a bug on the tracker.

-Stu
coco_vc#
3) No. You aren't uninstalling until you reach the UninstFiles page.
ahh, got it 🙂 Thx!

4) This could be a bug. On the NSIS project page (http://www.sf.net/projects/nsis) please post a bug on the tracker.
I would preffer to see first what is kichik answering to your reply from: here