#RequireAdmin
Opt('MustDeclareVars', 1)
Local $wbemFlagReturnImmediately, $wbemFlagForwardOnly, $colItems, $strComputer, $Output, $objWMIService, $objItem = ""
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""
$Output = $Output & "Computer: " & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM SoftwareLicensingProduct WHERE PartialProductKey <> Null", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
For $objItem In $colItems
$objItem.Activate()
$Output = $Output & "ApplicationID: " & $objItem.ApplicationID & @CRLF
$Output = $Output & "ID: " & $objItem.ID & @CRLF
$Output = $Output & "LicenseFamily: " & $objItem.LicenseFamily & @CRLF
$Output = $Output & "InstallationID: " & $objItem.OfflineInstallationId & @CRLF
$Output = $Output & "LicenseStatus: " & $objItem.LicenseStatus & @CRLF
if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
$Output=""
Next
Else
Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "SoftwareLicensingProduct" )
Endif
Func WMIDateStringToDate($dtmDate)
Return (StringMid($dtmDate, 5, 2) & "/" & _
StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
& " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc