I have the following code which works in XP, Vista and 7 which I took from WMI. It does not work in SBS 2008 however. I am assuming security center is not installed, but the WMI does return a value when run as a vbs, so I wondered if anyone could shed any light on how to return AV up to date in 2008 and R2?
Code:
AVUpToDate = False
Dim sCPath As String = ""
Try
Select Case Environment.OSVersion.Version.Major
Case "6"
sCPath = "\root\SecurityCenter2"
Case "5"
sCPath = "\root\SecurityCenter"
End Select
Dim computer As String = "." 'Environment.MachineName
Dim wmipath As String = "\\" & computer & sCPath
Dim query As String = "SELECT * FROM AntivirusProduct"
Dim searcher As New ManagementObjectSearcher(wmipath, query)
Dim results As ManagementObjectCollection = searcher.[Get]()
'do something with result
For Each result As ManagementObject In results
Me.lblAVVersion.Text = result("displayName").ToString()
Me.lblAVVersion.Visible = True
For Each result1 In results
If result("productState") >= 266240 Then
AVUpToDate = True
Else
AVUpToDate = False
End If
Next
Next
Catch
If Err.Number <> 0 Then
Me.lblAVVersion.Text = "Unable to check"
Me.lblAVVersion.ForeColor = Color.Red
Me.lblAVVersion.Visible = True
End If
End Try