1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
Public Function RemoteWin32_AVP(ByVal strComputer As String, ByVal strUser As String, _
ByVal strPwd As String, Optional ByVal strDomain As String = "Default") As String
Dim options As ConnectionOptions
options = New ConnectionOptions()
If strDomain = "Default" Then strDomain = strComputer
options.Username = strDomain & "\" & strUser
options.Password = strPwd
'options.Authority = "kerberos:" & strDomain
Dim scope As ManagementScope
scope = New ManagementScope( _
"\\" & strComputer & "\root\SecurityCenter", options)
Try
scope.Connect()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error while Connecting", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return "Error"
Exit Function
End Try
Dim query As ObjectQuery
query = New ObjectQuery( _
"SELECT * from AntiVirusProduct")
Dim searcher As ManagementObjectSearcher
searcher = New ManagementObjectSearcher(scope, query)
Dim queryCollection As ManagementObjectCollection
queryCollection = searcher.Get()
Dim m As ManagementObject
Dim str As String = String.Empty
For Each m In queryCollection
'Dim lvi As New ListViewItem
'lvi.Text = m("DisplayName").ToString
Try
Me.ListView1.Items.Add("Name")
Me.ListView1.Items(0).SubItems.Add(m("DisplayName").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("Name")
Me.ListView1.Items(0).SubItems.Add(m("n.a."))
End Try
Try
Me.ListView1.Items.Add("Version")
Me.ListView1.Items(1).SubItems.Add(m("VersionNumber").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("Version")
Me.ListView1.Items(1).SubItems.Add(m("n.a."))
End Try
Try
Me.ListView1.Items.Add("Company")
Me.ListView1.Items(2).SubItems.Add(m("CompanyName").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("Company")
Me.ListView1.Items(2).SubItems.Add(m("n.a."))
End Try
Try
Me.ListView1.Items.Add("Product Upto date")
Me.ListView1.Items(3).SubItems.Add(m("productUptoDate").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("Product Upto date")
Me.ListView1.Items(3).SubItems.Add(m("n.a."))
End Try
Try
Me.ListView1.Items.Add("On Access Scanning Enabled")
Me.ListView1.Items(4).SubItems.Add(m("onAccessScanningEnabled").ToString)
Catch ex As Exception
Me.ListView1.Items.Add("On Access Scanning Enabled")
Me.ListView1.Items(4).SubItems.Add(m("n.a."))
End Try
Application.DoEvents()
Next
For Each locColumn As ColumnHeader In Me.ListView1.Columns
locColumn.Width = -2
Next
Return "OK"
End Function
'Aufruf
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
RemoteWin32_AVP("Computer1", "User1", "PaSSwOrD1", "Domaine.com")
End Sub
|