Software Products Inventory WBEM
;==========================================================================================================================================
; Create a list of installed software products using the Win32_Product class using WBEM.
;
; 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 = "."

objLocator = ObjectOpen ("WbemScripting.SWbemLocator")
objService = objLocator.ConnectServer(strComputer, "root/cimv2", "", "")
objProducts = objService.InstancesOf("Win32_Product")

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
objService = 0
objLocator = 0

hdlFW = FileClose (hdlFW)

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