Check remote OS

delstar

Well-known member
Joined
Jun 9, 2006
Messages
59
Programming Experience
1-3
Alright, I'm writing a program that goes through a list of computers (obtained from AD) and gets WMI info from each of them. The problem is that some of the computers on the list aren't running Windows. The current check (code below) I have to tell if WMI is available on that computer seems to be running pretty slow. Does nayone have any ideas to make this more efficient?

Current check code :

VB.NET:
    Private Function TestConnection(ByVal computer As String)
        Dim myManagementScope As System.Management.ManagementScope
        Dim myConnectionOptions As New System.Management.ConnectionOptions
        With myConnectionOptions
            .Impersonation = System.Management.ImpersonationLevel.Impersonate
            .Authentication = System.Management.AuthenticationLevel.Packet
        End With
        Try
            My.Computer.Network.Ping(computer)
            Try
                myManagementScope = New System.Management.ManagementScope("\\" & computer & "\root\cimv2", myConnectionOptions)
                myManagementScope.Connect()
                If myManagementScope.IsConnected = False Then
                    Return False
                End If
                Return True
            Catch
                Return False
            End Try
        Catch ex As Exception
            Return False
        End Try
    End Function
 
Back
Top