- NSIS Discussion
- Un-installing a previous installation while installing a new version.
Archive: Un-installing a previous installation while installing a new version.
bdoherty
13th March 2002 20:26 UTC
Un-installing a previous installation while installing a new version.
If I have an installation already installed, and I know therefore that I have a un-install file. When I check to make sure my files are there can I give the user the option of uninstalling the original installation without aborting the new installation?
I have the following code:
; Check if we're about to try to install over an existing installation.
IfFileExists "$INSTDIR\MyAppReadme.htm" warn install
warn:
MessageBox MB_OK|MB_ICONSTOP "You are trying to install over an existing installation of MyAppReadme.$\nPlease uninstall the existing version and run the installer again."
Abort
install:
I assume I can use ExecWait to trigger the uninstMyApp.exe but I am unsure as to how to write this code or where this code will go in the NSI file.
:confused:
DuaneJeffers
14th March 2002 02:30 UTC
Yes, you can run the Uninstall App by using the ExecWait command, but you can do much more. Like Silently Uninstalling the application by using the UnInstallSilent tag. That way, when you run the new install, you can uninstall the previous app before using the new one.
-Duane
justin
14th March 2002 05:28 UTC
If you use ExecWait on the uninstaller it won't work, since the uninstaller will duplicate itself and exit immediately.
Instead, use this:
ExecWait '"$INSTDIR\uninstall.exe" /S _=$INSTDIR'
The /S will tell it to be silent, and the _=$INSTDIR tells it to immediately uninstall from $INSTDIR.
Note that if you do this, the uninstaller won't be able to remove itself, which should be OK, but any logic to detect whether the uninstall was complete in the uninstaller could cause popups (i.e. "could not remove program directory" if you put that in).
-Justin
DuaneJeffers
14th March 2002 08:36 UTC
Well Gee, you learn something new everyday.
Thanks J.
-Duane
bdoherty
14th March 2002 23:41 UTC
conditional branching
Ok, I think I get it. Now, how do I deal with it along with the MessageBox code I have above? I would like to give the users the option to un-install the previous installation, abort the current installation, or chose another directory and continue. I have no idea how to set up the conditional branching; any sample would be of great help.
Also, I assume once I uninstall the original app, if it is unable to remove itself, I can overwrite the original un-installer with a new one?
:hang:
Smile2Me
15th March 2002 07:11 UTC
Giving users the ability to select another dir at error (eg alread installed in this dir) is possible using .onNextPage after the initial dir selection has taken place. You can then check whether this is the dir that is already installed to (using registry or IfFileExists) and abort the function (so not continueing) if the user wants to select another dir. You could also use .onVerifyInstDir but the problem with this function is that it is triggered onKeyPress so when typing something in the dirselectionbox, after every letter, the message might appear...
For an example how to do this see this thread:
http://forums.winamp.com/showthread....hlight=regcode
Good luck,
greetz, Hendri.
Pomflain
18th March 2002 14:32 UTC
Re: conditional branching
Originally posted by bdoherty
Ok, I think I get it. Now, how do I deal with it along with the MessageBox code I have above? I would like to give the users the option to un-install the previous installation, abort the current installation, or chose another directory and continue. I have no idea how to set up the conditional branching; any sample would be of great help.
Also, I assume once I uninstall the original app, if it is unable to remove itself, I can overwrite the original un-installer with a new one?
:hang:
I might have you covered. This is almost exactly what I've done with a suite of installers and I think I've got it working pretty well now. What I do is detect the old installation and ask them if they want to uninstall or just continue with the new installation. Sometimes you just can't uninstall because something is messed up, so they have the option to just continue if something like that happens. If they chose to uninstal then the uninstaller is spawned off and the installer closes, but writes out its location from $CMDLINE. The uninstaller runs and once it completes, relaunches the installer and everything is good.
Sound like what you are looking for?
bdoherty
18th March 2002 19:57 UTC
Re: conditional branching
Sound's great!
I am looking for just that, can you post the code and/or email me the code?
:up:
Pomflain
18th March 2002 20:35 UTC
Re: Re: conditional branching
Originally posted by bdoherty
Sound's great!
I am looking for just that, can you post the code and/or email me the code?
:up:
Sure, what's your e-mail? Don't want to embarrass by posting my work on here...
Pomflain
18th March 2002 20:42 UTC
Re: conditional branching
Originally posted by bdoherty
Ok, I think I get it. Now, how do I deal with it along with the MessageBox code I have above? I would like to give the users the option to un-install the previous installation, abort the current installation, or chose another directory and continue. I have no idea how to set up the conditional branching; any sample would be of great help.
Also, I assume once I uninstall the original app, if it is unable to remove itself, I can overwrite the original un-installer with a new one?
:hang:
I might have you covered. This is almost exactly what I've done with a suite of installers and I think I've got it working pretty well now. What I do is detect the old installation and ask them if they want to uninstall or just continue with the new installation. Sometimes you just can't uninstall because something is messed up, so they have the option to just continue if something like that happens. If they chose to uninstal then the uninstaller is spawned off and the installer closes, but writes out its location from $CMDLINE. The uninstaller runs and once it completes, relaunches the installer and everything is good.
Sound like what you are looking for?
bdoherty
18th March 2002 22:08 UTC
conditional branching
I hear ya!
Thanks, this will really help me out!
My email is btdoherty@att.net
:hang:
jcagle
25th July 2003 20:09 UTC
Pomflain, could you send me this code as well? Thanks!
jpodtbc
23rd February 2007 17:38 UTC
Originally posted by justin
ExecWait '"$INSTDIR\uninstall.exe" /S _=$INSTDIR'
i couldn't get this to work until i looked at the nsis documentation which showed
_?=$INSTDIR
use that argument if you want to ExecWait your uninstaller.