我正在尝试从 Windows 7 或 8 中的 Windows 安全中心 2 获取 AntiVirus 的状态。我可以从“objAntiVirusProduct.displayName”中提取数据并显示信息,但是我似乎无法使 Hex 正常工作. 这就是我现在所拥有的。
Dim objWMIServiceAV,objAntiVirusProduct,colFiles,colItems,itemFile,AvStatus,PathToSignedProductExe
Dim strdisplayName,strproductState,strdefinitionState
Set objWMIServiceAV = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\SecurityCenter2")
Set colItems = objWMIServiceAV.ExecQuery("Select * from AntiVirusProduct")
For Each objAntiVirusProduct In colItems
Set colFiles = objWMIServiceAV.ExecQuery ("Select * from CIM_Datafile Where name = '" & PathToSignedProductExe & "'",,48)
For Each itemFile In colFiles
strdisplayName = (objAntiVirusProduct.displayName)
AvStatus = Hex(objAntiVirusProduct.ProductState)
If Mid(AvStatus, 2, 2) = "10" Or Mid(AvStatus, 2, 2) = "11" Then
strproductState = "Scanning Enabled"
ElseIf Mid(AvStatus, 2, 2) = "00" Or Mid(AvStatus, 2, 2) = "01" Then
strproductState = "Scanning Not Enabled"
errors("AntiVirus Product State: ") = "Off"
End If
If Mid(AvStatus, 4, 2) = "00" Then
strdefinitionState = "AntiVirus up-to-date"
ElseIf Mid(AvStatus, 4, 2) = "10" Then
strdefinitionState = "AntiVirus outdated"
End If
objFile.Write "AntiVirus Display Name= " & strdisplayName & vbNewLine
objFile.Write "AntiVirus Scanning Status= " & strproductState & vbNewLine
objFile.Write "AntiVirus Definition Status= " & strdefinitionState & vbNewLine
Next
Next
我错过了什么?
编辑:我被要求提供一些我的输出示例。
我收到的是:
AntiVirus Display Name= Norton Endpoint Protection
AntiVirus Scanning Status=
AntiVirus Definition Status=
我期待的是:
AntiVirus Display Name= Norton Endpoint Protection
AntiVirus Scanning Status= (SCANNING STATUS)
AntiVirus Definition Status= (AV UPDATE STATUS)