- NSIS Discussion
- ExecWait uninstaller.exe on XP
Archive: ExecWait uninstaller.exe on XP
hermanator
5th April 2003 23:28 UTC
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.
Joel
6th April 2003 00:27 UTC
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]
:)
deguix
6th April 2003 06:48 UTC
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)
kichik
6th April 2003 07:02 UTC
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.
virtlink
6th April 2003 09:14 UTC
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. ;)
kichik
6th April 2003 16:50 UTC
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.
vtsaran
7th April 2003 17:21 UTC
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
kichik
7th April 2003 17:26 UTC
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.
hermanator
7th April 2003 21:19 UTC
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
Yovav
13th May 2003 01:47 UTC
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.
|
Sunjammer
13th May 2003 08:34 UTC
Posting a complete example at the Archive would be better than emailing it to a single person.