Function GetW7AVinfo(optional $_Machine)
Dim $_oSWbem ; COM Object pointer for query
Dim $_colItems, $_Item ; collection of items, enumerator var
Dim $_Product ; Product type to retrieve
Dim $_Av[4] ; 5-element array to return
; Define localhost if Machine Name not provided
If Not $_Machine $_Machine = '.' EndIf
; Define product to find
$_Product = 'AntiVirusProduct'
$_oSWbem = GetObject('winmgmts:\\' + $_Machine + '\root\SecurityCenter2')
If @ERROR Exit @ERROR EndIf
; Get collection of items for product type
$_colItems = $_oSWbem.ExecQuery('Select * From ' + $_Product)
If @ERROR Exit @ERROR EndIf
; process the collection and assign the desired object values
For Each $Item In $colItems
$_Av[0] = $Item.productState
$_Av[1] = $Item.displayName
$_Av[2] = $Item.instanceGuid
$_Av[3] = $Item.pathToSignedProductExe
$_Av[4] = $Item.pathToSignedReportingExe
Next
; DEBUGGING
$_Product @CRLF ; show current product type
Join($_Av, @CRLF) @CRLF ; show array, 1 element per line
; Select $iProductState = Hex($colItem.productState, 8)
; Case ($iProductState, 5, 2) = '00' or '01'
; $aReturn[5] = 'Disabled'
; Case '10', '11'
; $aReturn[5] = 'Enabled'
; EndSelect
; Prepare to return the data
$GetW7AVinfo = $_Av
; Validate results of query and return exit status accordingly
If $_Av[0] = 0
; ? 'Something not installed' ; BAD! Do not generate output from UDFs
Exit 2 ; not found, optionally use "87" for invalid value
EndIf
Exit 0 ; success!
EndFunction