- NSIS Discussion
- Migrating from MSI: uninstall previous version of application
Archive: Migrating from MSI: uninstall previous version of application
joostn
2nd April 2003 21:21 UTC
Migrating from MSI: uninstall previous version of application
Hi,
I'm sure I'm not the first one migrating from MSI to NSIS.. Anyone have an example how to uninstall the previous version of my application, that was installed using MSI, from an NSIS installer which installs the new version of my application?
Thanks
Joost
psyke
3rd April 2003 05:32 UTC
Hi Joost. :)
Hmmm I can't say for certain if this will help, but you should be able to at least start the uninstall from NSIS with the following command:
ExecWait '"msiexec.exe" /x Example.msi'
The reason I emphasized
start is that, provided everything is ok the uninstaller will launch, but if msiexec simply does a little bit and then forks or starts doing the real uninstall work from some temp executable, execwait will return 'early' as far as you're concerned.
This is actually correct behaviour, ExecWait will wait for msiexec.exe to finish... but you want the *uninstaller* to finish, and msiexec.exe may not be active for the entire duration of the uninstall.
Anyway, just test out the command and see how it goes. :)
If you need more info on MSI (which I doubt since you made the MSI installer, but anyway)
here's where I found info on the command line parameters to msiexec.
Salaam/Peace.
joostn
3rd April 2003 07:53 UTC
Hi Psyke,
Thanks for the feedback. I need to do a few more things:
1. find out whether msiexec actually exists on the computer (older Windows versions didn't have MSI)
2. find out whether my program was installed or not
Both could probably be determined from the registry, but before I try to reinvent the wheel, I hope that someone has a ready-cooked example..
Thanks
Joost
joostn
3rd April 2003 10:56 UTC
Okay, it wasn't that difficult after all:
Function UninstallMSI
; $R0 should contain the GUID of the application
push $R1
ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$R0" \
"UninstallString" ;UninstallString
StrCmp $R1 "" UninstallMSI_nomsi
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION \
"A previous version of ${MUI_PRODUCT} was found.\
It is recommended that you uninstall it first.$\n$\n\
Do you want to do that now?" IDNO UninstallMSI_nomsi IDYES UninstallMSI_yesmsi
Abort
UninstallMSI_yesmsi:
ExecWait '"msiexec.exe" /x $R0'
MessageBox MB_OK|MB_ICONINFORMATION \
"Click OK to continue upgrading your version of ${MUI_PRODUCT}"
UninstallMSI_nomsi:
pop $R1
FunctionEnd
From the main Section I then do the following:
push $R0
StrCpy $R0 "{48E5A72D-whatever-xxxx}"
Call UninstallMSI
pop $R0
In my case I had to do this for every product code for each previous version of my application.
NSIS is really great!!
Joost
virtlink
3rd April 2003 11:00 UTC
You should post this code in the NSIS archive.
psyke
3rd April 2003 16:16 UTC
hey Joost, you're quite welcome, wish I could've been more help. :)
NSIS is indeed, great. :D I'm glad to see you were able to come up with a straightforward way to do what you needed.
There wasn't a cooked example ready for you, but now that you've done the 'cooking' someone down the road will probably benefit from it. ;)
Salaam/Peace.
joostn
3rd April 2003 16:33 UTC
I hope so.. I've added my code to the archives!
kichik
3rd April 2003 16:52 UTC
Thank you for your addition. To make your code easier to use, and more standard you can use Exch instead of Push, StrCpy, Call, Pop. For example:
PrintParm
Exch$0 # parm
DetailPrint $0
Pop$0
FunctionEnd
>#...
>Push "print this"
>Call PrintParm
>
RossW
20th June 2006 19:27 UTC
Can someone point me to the Archives? I can't find it at http://nsis.sf.net/archive
JasonFriday13
21st June 2006 00:42 UTC
It is now called the Developer Center, and now uses a wiki to store the information.
RossW
21st June 2006 02:20 UTC
Thanks Jason, but what section can I find this code?
Never mind. Found it at http://nsis.sourceforge.net/Uninstalling_a_previous_MSI
onad
27th June 2006 17:24 UTC
This included delphi file might be of help for some...
at least it is of help for me uninstalling MSI ;)