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
|
Sub Button1_Click(sender As Object, e As EventArgs)
Dim co As ConnectionOptions = New ConnectionOptions()
Dim TestConnection As Boolean
With co
.Impersonation = System.Management.ImpersonationLevel.Impersonate
'* Use next line for XP
.Authentication = System.Management.AuthenticationLevel.Packet
'* Use next line for Win prior XP
'.Authentication = System.Management.AuthenticationLevel.Connect
End With
co.Username = "Administrateur"
co.Password = "admin"
'Dim theScope As New ManagementScope("\\" +DropDownList1.Text+ "\root\cimv2",co)
Dim theScope As New ManagementScope("\\" +DropDownList1.Text+ "\root\cimv2")
Dim theQuery As New System.Management.ObjectQuery("SELECT * From Win32_Process ")
Dim theSearcher As New ManagementObjectSearcher(theScope, theQuery)
'Try
Dim theCollectionOfResults As ManagementObjectCollection = theSearcher.Get()
For Each currentResult As ManagementObject In theCollectionOfResults
ListBox1.Text = Process.ProcessName
Next
' Catch com_ex As System.Runtime.InteropServices.COMException When com_ex.ErrorCode = &H800706BA
'Response.write("Machines are unvailable:" & ipadress &"It may be off line or the firewallsettings are preventing the connection")
'Catch ua_ex As System.UnauthorizedAccessException
' Response.write("The Remote PC refused the connection This is most likely due to a permissions issue.")
'Catch wmi_ex As Exception When wmi_ex.Exception = Management.ManagementStatus.AccessDenied
'Response.write("You do not have sufficient privileges on the remote PC:" & ipadress)
'Catch ex As Exception
'If IsNothing(ex.InnerException) Then
'Response.write("Could not get initial data")
'Else
'Response.write("Could not get initial data:" & ex.InnerException.Message)
'End if
'End Try
End Sub |
Partager