Uninstalling a previous MSI: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.)
m (Updated author links.)
Line 1: Line 1:
{|align=right
|<small>Author: [[{{ns:2}}:anonymous|anonymous]] ([[{{ns:3}}:anonymous|talk]], [[{{ns:-1}}:Contributions/anonymous|contrib]])</small>
|}
<br style="clear:both;">
== 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:
Line 23: Line 27:
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.
Page author: [[User:anonymous|anonymous]]

Revision as of 03:05, 30 April 2005

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.