Software Products Inventory WMI
;==========================================================================================================================================
; Create a list of installed software products using the Win32_Product class using WMI.
;
; See also: http://msdn.microsoft.com/en-us/library/aa394378(VS.85).aspx
; See also: http://msdn.microsoft.com/de-de/library/cc405527.aspx
;
; *** Note: Windows Server 2003, Windows XP, and Windows 2000:  This property is not available.
;
; Detlev Dalitz.20091219.
;==========================================================================================================================================

strFileOut = DirScript () : "Win32_Product." : StrInsert (StrReplace (TimeYmdHms (), ":", ""), ".", "", 9) : ".txt"
hdlFW = FileOpen (strFileOut, "WRITE")

;strComputer = Environment ("COMPUTERNAME")
strComputer = "."

strCIM = "winmgmts:{impersonationLevel=impersonate}!\\" : strComputer : "\root\cimv2"

; Inventory all the software installed on a computer.
strSelect = "Select * from Win32_Product"

; Determine if "Microsoft Office Excel Viewer 2003" is installed.
;strSelect = "Select * from Win32_Product Where Caption Like '%%Excel Viewer%%'"

; Determine if ".Net" products are installed.
;strSelect = "Select * from Win32_Product Where Caption Like '%% .Net%%'"

objWMIService = ObjectGet (strCIM)
objProducts = objWMIService.ExecQuery(strSelect)

intItemCount = 0
ForEach objProduct In objProducts
   If ObjectTypeGet (objProduct) == "EMPTY" Then Break
   intItemCount = intItemCount + 1
   strMsgText = "ItemCount: " : intItemCount : @CRLF
   ;strMsgText = strMsgText : "AssignmentType" : objProduct.AssignmentType : @CRLF ; *** See note.
   strMsgText = strMsgText : "Caption: " : objProduct.Caption : @CRLF
   strMsgText = strMsgText : "Description: " : objProduct.Description : @CRLF
   ;strMsgText = strMsgText : "HelpLink: " : objProduct.HelpLink : @CRLF ; *** See note.
   ;strMsgText = strMsgText : "HelpTelephone: " : objProduct.HelpTelephone : @CRLF ; *** See note.
   strMsgText = strMsgText : "IdentifyingNumber: " : objProduct.IdentifyingNumber : @CRLF
   strMsgText = strMsgText : "InstallDate: " : objProduct.InstallDate : @CRLF
   strMsgText = strMsgText : "InstallDate2: " : objProduct.InstallDate2 : @CRLF
   strMsgText = strMsgText : "InstallLocation: " : objProduct.InstallLocation : @CRLF
   ;strMsgText = strMsgText : "InstallSource: " : objProduct.InstallSource : @CRLF ; *** See note.
   strMsgText = strMsgText : "InstallState: " : objProduct.InstallState : @CRLF
   ;strMsgText = strMsgText : "Language: " : objProduct.Language : @CRLF ; *** See note.
   ;strMsgText = strMsgText : "LocalPackage: " : objProduct.LocalPackage : @CRLF ; *** See note.
   strMsgText = strMsgText : "Name: " : objProduct.Name : @CRLF
   strMsgText = strMsgText : "PackageCache: " : objProduct.PackageCache : @CRLF
   ;strMsgText = strMsgText : "PackageCode: " : objProduct.PackageCode : @CRLF ; *** See note.
   ;strMsgText = strMsgText : "PackageName: " : objProduct.PackageName : @CRLF ; *** See note.
   ;strMsgText = strMsgText : "ProductID: " : objProduct.ProductID : @CRLF ; *** See note.
   ;strMsgText = strMsgText : "RegCompany: " : objProduct.RegCompany : @CRLF ; *** See note.
   ;strMsgText = strMsgText : "RegOwner: " : objProduct.RegOwner : @CRLF ; *** See note.
   strMsgText = strMsgText : "SKUNumber: " : objProduct.SKUNumber : @CRLF
   ;strMsgText = strMsgText : "Transforms: " : objProduct.Transforms : @CRLF ; *** See note.
   ;strMsgText = strMsgText : "URLInfoAbout: " : objProduct.URLInfoAbout : @CRLF ; *** See note.
   ;strMsgText = strMsgText : "URLUpdateInfo: " : objProduct.URLUpdateInfo : @CRLF ; *** See note.
   strMsgText = strMsgText : "Vendor: " : objProduct.Vendor : @CRLF
   strMsgText = strMsgText : "Version: " : objProduct.Version : @CRLF
   ;strMsgText = strMsgText : "WordCount: " : objProduct.WordCount : @CRLF ; *** See note.
   FileWrite (hdlFW, strMsgText)
Next

objProduct = 0
objProducts = 0
objWMIService = 0

hdlFW = FileClose (hdlFW)

Run (strFileOut, "")
Exit
;==========================================================================================================================================