Archive: ExecWait uninstaller.exe on XP


ExecWait uninstaller.exe on XP
  I'm doing what probably many others are doing, which is to try to automatically uninstall previous versions of my app during installation.

First my installer reads the uninstall string into $R2 from the registry then tries to uninstall the previous version as follows (I'm now using v2.0b3, and it only tries to uninstall versions built by v2.0b+):

ExecWait '$R2 /S _?=$INSTDIR'

Note: The FAQ says that $R2 should be put inside quotes (in case of spaces in the path), but as of v2.0b3 doing so causes errors.

On Win2k this will work fine, but on XP everything seems to work as it should except that the uninstaller does not remove the files it is supposed to. Desktop and Start Menu icons are removed aswell as registry settings, but the directory containing the installed files remains.

Note: The instruction in the uninstaller to remove that dir is:
RMDir /r "$INSTDIR"

Can anyone shed some light on this? Also I can't find the parameters for the uninstaller documented anywhere.


look at the:
${NSISDIR}\Examples\makensis.nsi
You should first detect the installed files or old version
of your app, than continue with installed
I don't see why the

RMDir /r $INSTDIR  

doesn't remove the folder.
[edit]Maybe because you put the ""[/edit]
:)

You are running a program that are in the folder when you try to remove the folder (or almost to remove the folder)? (except the uninstaller program)


I don't have a lot of time to really get into to this right now because I have to go out in 5 minutes but deguix have a point. When you call the uninstaller this way it doesn't fork and thus can't delete itself. You should first copy it to $TEMP and call it from there. I don't know how the entire RMDir /r command could fails because of this but it's worth a try.


The Docs say that you have to use quotes around the uninstaller file too, even if that name doesn't contain quotes:

ExecWait '"$R2" /S _?=$INSTDIR' 

And maybe you should first copy the uninstaller to the $TEMP directory, call it from there, and then remove it after uninstall. I think that because of the uninstaller's presence in the $INSTDIR, that directory can't be removed. You should check the error flag to catch this error.

Something like this should work:

Delete $TEMPuninstaller.exe

CopyFiles/SILENT $R2 $TEMP
ExecWait '"$TEMP\uninstaller.exe" /S _?=$INSTDIR'
>Delete $TEMPuninstaller.exe
>
The above code assumes that the uninstaller's filename is 'uninstaller.exe'. If not, or if not certain, you should retrieve it from $R2.

Warning: The forum has deleted the backslashes, but I assume that you know where they should be written. ;)

Note: The FAQ says that $R2 should be put inside quotes (in case of spaces in the path), but as of v2.0b3 doing so causes errors.
There are two possible reasons I can think of:
1) There are already quotes in the registry.
2) You are using b3 from CVS and not final b3.

I also noticed that the return code for the uninstaller is always 0. How can I check if my uninstaller exited correctly or with errors, say, if the user pressed "cancel" on the uninstall screen.
I put

ExecWait "$INSTDIR\${UNINSTALLER}" $R9
MessageBox MB_OK "The value for R9 is $R9$\n"

It would always come back with the value of 0, regardless of whether the "cancel" button was pressed or the "finish" one.
Anybody can explain please?

Thanks,
Victor


If you executes the uninstaller this way it will return right away with the return value 0. You have to execute it as hermanator said and as the FAQ states, with _?=$INSTDIR. This way the installer will really wait for the uninstaller and you should get the right return value.


Thanks for the responses..

There were two problems:

1) I had set the uninstall reg string improperly as follows:

'"$INSTDIR\gaim-uninst.exe"'

This was the reason why I could not do
ExecWait '"$R2" /S _?=$INSTDIR'
without an error.

2) Copying the uninstaller to the TEMP dir and running it fixed my problem. I should mention that you need to make sure that you pass the actual install dir of the old installation as the _? param. Passing $INSTDIR will fail in case the user has choosen a new location.

- Herman


Re: ExecWait uninstaller.exe on XP
  Quote:


Hi,

How do U check it old version is installed ?

if possible please post or send me your example code

10X in advanced, Yovav.

Originally posted by hermanator
I'm doing what probably many others are doing, which is to try to automatically uninstall previous versions of my app during installation.

First my installer reads the uninstall string into $R2 from the registry then tries to uninstall the previous version as follows (I'm now using v2.0b3, and it only tries to uninstall versions built by v2.0b+):

ExecWait '$R2 /S _?=$INSTDIR'

Note: The FAQ says that $R2 should be put inside quotes (in case of spaces in the path), but as of v2.0b3 doing so causes errors.

On Win2k this will work fine, but on XP everything seems to work as it should except that the uninstaller does not remove the files it is supposed to. Desktop and Start Menu icons are removed aswell as registry settings, but the directory containing the installed files remains.

Note: The instruction in the uninstaller to remove that dir is:
RMDir /r "$INSTDIR"

Can anyone shed some light on this? Also I can't find the parameters for the uninstaller documented anywhere.


Posting a complete example at the Archive would be better than emailing it to a single person.