Uninstalling a previous MSI: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library)
 
(Extra installshield info)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{PageAuthor|anonymous}}
== 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 16: 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 24: Line 29:
Joost N.
Joost N.


Page author: anonymous
== Information for InstallShield users ==
 
Whilst migrating from an InstallShield product to NSIS, I found that the uninstall string is stored in a 'unique' fashion. The Registry entry looked like this:-
 
HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\InstallShield_{GUID}
 
See also [[Removing MSI packages with MSI related functions]]
 
[[Category:Other Products Version Detection Functions]]

Latest revision as of 14:19, 26 September 2008

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.

Information for InstallShield users

Whilst migrating from an InstallShield product to NSIS, I found that the uninstall string is stored in a 'unique' fashion. The Registry entry looked like this:-

HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\InstallShield_{GUID}

See also Removing MSI packages with MSI related functions