Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > how to uninstall an MSI programmatically if productcode is not provided
 

how to uninstall an MSI programmatically if productcode is not provided

Hi,

I need to uninstall an MSI from my code but i do not know the product code so i cannot use msiexec/x {Product Code}. Is there another way to do this? Can i search the registry for the product code? What search string should i use? Thanks!
zette  Monday, July 13, 2009 8:13 AM


Use a script like this to list the ProductCodes of everything installed on that system :

Option Explicit
Public installer, fullmsg, comp, prod, a, fso, pname, ploc, pid,contxt, sid, psorce, pcache, pvers

Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("prodex.txt", True)

' Connect to Windows Installer object
Set installer = CreateObject("WindowsInstaller.Installer")
a.writeline ("Products")
'on error resume next
For Each prod In installer.ProductsEx("", "", 7)
   pid = prod.ProductCode
   contxt = prod.Context
   sid=prod.usersid
   pname = prod.InstallProperty("InstalledProductName")
   psorce=prod.InstallProperty( "InstallSource")
   ploc =prod.InstallProperty( "InstallLocation")  
   pcache = prod.InstallProperty("LocalPackage") 
  pvers=prod.InstallProperty("VersionString")
   a.writeline (pid & " " & pname & " " & pvers & " installed at <" & ploc & "> from " & psorce & " Context " & contxt)
Next

Phil Wilson
PhilWilson  Monday, July 13, 2009 8:01 PM


Use a script like this to list the ProductCodes of everything installed on that system :

Option Explicit
Public installer, fullmsg, comp, prod, a, fso, pname, ploc, pid,contxt, sid, psorce, pcache, pvers

Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("prodex.txt", True)

' Connect to Windows Installer object
Set installer = CreateObject("WindowsInstaller.Installer")
a.writeline ("Products")
'on error resume next
For Each prod In installer.ProductsEx("", "", 7)
   pid = prod.ProductCode
   contxt = prod.Context
   sid=prod.usersid
   pname = prod.InstallProperty("InstalledProductName")
   psorce=prod.InstallProperty( "InstallSource")
   ploc =prod.InstallProperty( "InstallLocation")  
   pcache = prod.InstallProperty("LocalPackage") 
  pvers=prod.InstallProperty("VersionString")
   a.writeline (pid & " " & pname & " " & pvers & " installed at <" & ploc & "> from " & psorce & " Context " & contxt)
Next

Phil Wilson
PhilWilson  Monday, July 13, 2009 8:01 PM
Thanks!
zette  Thursday, July 16, 2009 1:18 AM

You can use google to search for other answers

Custom Search

More Threads

• Environment Variables in Windows Installer
• Conditional usage of .NET framework
• AppUpdater on WinXP client?
• VB.NET application deployment issue
• Problems deploying on Vista
• Windows Service Uninstall Fails During Application Update
• The remote server returned an error: (502) Bad Gateway - System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
• Upgrade programs on the go ?
• Click Once access to path denied
• How to distribute Visual C++ / C Runtime Library with Clickonce app