Skip to content
⌘ NSIS Forum Archive

Uninstaller error levels

9 posts

Nniol#

Uninstaller error levels

Hi

I need to get the error levels from an uninstaller...

I see

CopyFiles $INSTDIR\uninstaller.exe $TEMP
ExecWait '"$TEMP\uninstaller.exe" _?=$INSTDIR' $0
DetailPrint "uninstaller set error level $0"


In section D.1 in the manual.... so how does this work?

Where do I put this??? I have my normal uninstall section does this go in there, if so where does the uninstall code go?

Nniol
Red Wine#
I'm not quite sure what are you trying to achieve. The manual is pretty clear:

Note that uninstallers copy themselves to the temporary directory and execute from there so the original uninstaller can be deleted. This means the error level the uninstaller sets is not available to the executing process, unless it simulates this copy process and executes the copied uninstaller. To simulate this process, use:
CopyFiles $INSTDIR\uninstaller.exe $TEMP
ExecWait '"$TEMP\uninstaller.exe" _?=$INSTDIR' $0
DetailPrint "uninstaller set error level $0"
Also this code executes the uninstaller of installation A from the installer of installation B. The included in examples makensis.nsi is pretty self explained on that.
orhuidobro#
Hi, this post is pretty old, but things didn't change much in NSIS.
Quoting the latest post:
Originally Posted by Red Wine View Post
Also this code executes the uninstaller of installation A from the installer of installation B. The included in examples makensis.nsi is pretty self explained on that.
I need to get a return code from my uninstaller, but I don't have installation A and installation B.
My uninstaller is going to be executed by a 3rd party uninstaller (I can't modify it), and that 3rd party uninstaller expect a return code from my uninstaller.
If I put these lines in my code, they are executed recursively:
CopyFiles $INSTDIR\uninstaller.exe $TEMP
ExecWait '"$TEMP\uninstaller.exe" _?=$INSTDIR' $0
The installer copies itself to $TEMP and executes itself, resulting in another copy and execution, and so on.

Is there a way to do what I need?

Thank you.
Anders#
Originally Posted by orhuidobro View Post
My uninstaller is going to be executed by a 3rd party uninstaller (I can't modify it), and that 3rd party uninstaller expect a return code from my uninstaller.
Can this uninstaller pass a parameter to the NSIS uninstaller? If not, it is not going to be possible to wait for the real NSIS uninstaller...
orhuidobro#
Originally Posted by Anders View Post
Can this uninstaller pass a parameter to the NSIS uninstaller?
Hi Anders!
Actually, I'm not sure if I can get that, but I can try. I do know that installer isn't made with NSIS.
In case I can get it, which parameter should I pass? My uninstaller must run silently.
Thanks and best regards.
Afrow UK#
How about having them run an included wrapper executable which itself executes the uninstaller with the required parameters and returns its exit code?

To run the uninstaller silently, use the case sensitive /S switch (must come before _?=). You could also just add SilentUninstall silent if it should always be ran silently.

Stu
Anders#
Originally Posted by Afrow UK View Post
How about having them run an included wrapper executable which itself executes the uninstaller with the required parameters and returns its exit code?
Where is he supposed to store this wrapper? In $InstDir? Then you are back to square one again and you are unable to delete $InstDir.

The best option might actually be to use the selfdelete plugin but I'm not sure if that thing works on Vista+
Afrow UK#
Originally Posted by Anders View Post
Where is he supposed to store this wrapper? In $InstDir? Then you are back to square one again and you are unable to delete $InstDir.

The best option might actually be to use the selfdelete plugin but I'm not sure if that thing works on Vista+
SelfDel works up to and including Windows 8 (32/64-bit).

Stu
orhuidobro#
Hi Afro UK and Anders.
Actually, I tried both of your suggestions (and both of them worked)!

Originally Posted by Afrow UK View Post
How about having them run an included wrapper executable which itself executes the uninstaller with the required parameters and returns its exit code?
I wrote my own wrapper, and it worked like a charm. But I noted that still have to ask for the 3rd. party installer to locate that wrapper outside my INSTDIR, and execute it.

So I tried the Anders proposal:
Originally Posted by Anders View Post
Can this uninstaller pass a parameter to the NSIS uninstaller?
The people who writes the 3rd party uninstaller made the requested modifications, and it worked flawlessly.

Thanks a lot for your disinterested help (both of you)!

I think the included documentation isn't clear enough, but you really helped me to get the things working.