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
 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'")
 Set Rec = View.Fetch
 If Not Rec Is Nothing Then
 End If
End Function

Read Full Post »