Mitunter benötigt man in seiner Anwendung informationen darüber, ob und welches Antivierenprogramm auf einem System eingesetzt ist.
Der nachfolgende Snippet ermittel diese Information und gibt Sie in einem String wieder aus.
'Da wir den Stringbuilder verwenden
Imports System.Text
Private Function GetAVInformation(ByVal strSystem As String) As String
Dim strComputer As String = String.Empty
Dim wmiNS As String = String.Empty
Dim wmiQuery As String = String.Empty
Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Dim strSB As New StringBuilder
Try
'Wenn lokales System
If strSystem = System.Environment.MachineName Then
strComputer = "."
Else
strComputer = strSystem
End If
wmiNS = "\root\securityCenter"
wmiQuery = "Select * from AntiVirusProduct"
objWMIService = GetObject("winmgmts:\\" & strComputer & wmiNS)
colItems = objWMIService.ExecQuery(wmiQuery)
For Each objItem In colItems
Try
strSB.AppendLine("Antivirus Company: " & vbTab & vbTab & objItem.companyName.ToString)
Catch ex As Exception
strSB.AppendLine("Antivirus Company: " & vbTab & vbTab & "Nicht ermittelbar")
End Try
Try
strSB.AppendLine("Displayname:" & vbTab & vbTab & vbTab & objItem.displayName.ToString)
Catch ex As Exception
strSB.AppendLine("Displayname:" & vbTab & vbTab & vbTab & "Nicht ermittelbar")
End Try
Try
strSB.AppendLine("On AccessScanning:" & vbTab & vbTab & objItem.onAccessScanningEnabled.ToString)
Catch ex As Exception
strSB.AppendLine("On AccessScanning:" & vbTab & vbTab & "Status nicht ermittelbar")
End Try
Try
strSB.AppendLine("Path To Enable On Access UI:" & vbTab & objItem.pathToEnableOnAccessUI.ToString)
Catch ex As Exception
strSB.AppendLine("Path To Enable On Access UI:" & "Pfad nicht auslesbar")
End Try
Try
strSB.AppendLine("Path To Update UI:" & vbTab & objItem.pathToUpdateUI.ToString)
Catch ex As Exception
strSB.AppendLine("Path To Update UI:" & vbTab & "Nicht ermittelbar")
End Try
Try
If objItem.productUptoDate.ToString.ToLower = "true" Then
strSB.AppendLine("AV Definitions Up To Date:" & vbTab & vbTab & "Pattern sind aktuell")
Else
strSB.AppendLine("AV Definitions Up To Date:" & vbTab & vbTab & "Pattern sind veraltet")
End If
Catch ex As Exception
strSB.AppendLine("AV Definitions Up To Date:" & vbTab & vbTab & "Status nicht ermittelbar")
End Try
Try
strSB.AppendLine("AV Version:" & vbTab & vbTab & vbTab & objItem.versionNumber.ToString)
Catch ex As Exception
strSB.AppendLine("AV Version:" & vbTab & vbTab & vbTab & "Version nicht feststellbar")
End Try
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Return strSB.ToString
End Function
Kommentare zum Snippet