Removing MSI packages with MSI related functions: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
m (Adding new author and category links.)
Line 1: Line 1:
{|align=right
{{PageAuthor|MathiasSimmack}}
|<small>Author: [[{{ns:2}}:MathiasSimmack|MathiasSimmack]] ([[{{ns:3}}:MathiasSimmack|talk]], [[{{ns:-1}}:Contributions/MathiasSimmack|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==
This is an extension to [[Uninstalling a previous MSI (Windows installer package)]]. It's another version to remove an installed MSI product. I wrote a simple function and a few symbols:
This is an extension to [[Uninstalling a previous MSI (Windows installer package)]]. It's another version to remove an installed MSI product. I wrote a simple function and a few symbols:
Line 48: Line 46:
Mathias.
Mathias.


[[{{ns:14}}:Other Products Version Detection Functions]]
[[Category:Other Products Version Detection Functions]]

Revision as of 13:40, 24 June 2005

Author: MathiasSimmack (talk, contrib)


Description

This is an extension to Uninstalling a previous MSI (Windows installer package). It's another version to remove an installed MSI product. I wrote a simple function and a few symbols:

How To Use

What you need is the ProductID (ProductCode) of your previous MSI installation. Send it onto the stack and call the function

Push "{48E5A72D-whatever-xxxx}"
call CallMsiDeinstaller

The Function

!define OLDVERSIONWARNING \
  "Old version found. Do U want to remove it?"
!define OLDVERSIONREMOVEERROR \
  "There was a problem removing the software ... Sorry"
 
 
!define INSTALLSTATE_DEFAULT "5"
!define INSTALLLEVEL_MAXIMUM "0xFFFF"
!define INSTALLSTATE_ABSENT "2"
!define ERROR_SUCCESS "0"
 
 
Function CallMsiDeinstaller
  Pop $R0
 
  System::Call "msi::MsiQueryProductStateA(t '$R0') i.r0"
  StrCmp $0 "${INSTALLSTATE_DEFAULT}" 0 Done
 
  MessageBox MB_YESNO|MB_ICONQUESTION "${OLDVERSIONWARNING}" \
  IDNO BreakMe
 
  System::Call "msi::MsiConfigureProductA(t '$R0', \
    i ${INSTALLLEVEL_MAXIMUM}, i ${INSTALLSTATE_ABSENT}) i.r0"
  StrCmp $0 ${ERROR_SUCCESS} Done
 
    MessageBox MB_OK|MB_ICONEXCLAMATION \
    "${OLDVERSIONREMOVEERROR}"
 
  BreakMe:
    Abort
 
  Done:
FunctionEnd

Mathias.