Feeds:
Posts
Comments

Posts Tagged ‘WindowsInstaller’

In looking for a way to retrieve the ProductCode from an MSI I came across this. Two important points: One, this uses the windows installer object and can be queried using SQL effectively, Two, the different parameters for opening the database can be found in the MSDN, but I found 2 worked better than 0.

 

Function GetMSIProductCode(msi) ' Return the Product Code from a given msi
 On Error Resume Next
 GetMSIProductCode=""
 If msi = "" Then Exit Function End If
 
 Dim FS, TS, WI, DB, View, Rec
 Set WI = CreateObject("WindowsInstaller.Installer")
 Set DB = WI.OpenDatabase(msi,2)
 If Err.number Then Exit Function End If
 
 Set View = DB.OpenView("Select `Value` From Property WHERE `Property` ='ProductCode'")
 View.Execute
 Set Rec = View.Fetch
 If Not Rec Is Nothing Then
  GetMSIProductCode=Rec.StringData(1)
 End If
End Function

Read Full Post »