Uninstalling a previous MSI: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Adding new author and category links.) |
Villarinho (talk | contribs) (+link) |
||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
I migrated my software from an MSI installer to NSIS. Upon installing the new version of my software, I first needed to uninstall the previous MSI package. Here's how I did it: | I migrated my software from an MSI installer to NSIS. Upon installing the new version of my software, I first needed to uninstall the previous MSI package. Here's how I did it: | ||
== The Script ==
<highlight-nsis>
Function UninstallMSI | == The Script == | ||
<highlight-nsis> | |||
Function UninstallMSI | |||
; $R0 should contain the GUID of the application | ; $R0 should contain the GUID of the application | ||
push $R1 | push $R1 | ||
Line 18: | Line 20: | ||
</highlight-nsis> | </highlight-nsis> | ||
From the main Section I then do the following: | From the main Section I then do the following: | ||
<highlight-nsis>
push $R0 | <highlight-nsis> | ||
push $R0 | |||
StrCpy $R0 "{48E5A72D-whatever-xxxx}"; the MSI's ProductID of my package | StrCpy $R0 "{48E5A72D-whatever-xxxx}"; the MSI's ProductID of my package | ||
Call UninstallMSI | Call UninstallMSI | ||
Line 25: | Line 28: | ||
In my case I had to do this for every ProductID for each previous version of my application. | In my case I had to do this for every ProductID for each previous version of my application. | ||
Joost N. | Joost N. | ||
See also [[Removing MSI packages with MSI related functions]] | |||
[[Category:Other Products Version Detection Functions]] | [[Category:Other Products Version Detection Functions]] |
Revision as of 13:11, 2 August 2006
Author: anonymous (talk, contrib) |
Description
I migrated my software from an MSI installer to NSIS. Upon installing the new version of my software, I first needed to uninstall the previous MSI package. Here's how I did it:
The Script
Function UninstallMSI ; $R0 should contain the GUID of the application push $R1 ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$R0" "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}"; the MSI's ProductID of my package Call UninstallMSI pop $R0
In my case I had to do this for every ProductID for each previous version of my application. Joost N.