none
Obtain NIC Info from Win32_NetworkAdapter & NetworkAdapterConfiguration RRS feed

  • Question

  • I am obtaining system information via the Win32_ComputerSystem class with the below code and was hoping to gather the NIC info from NetworkAdapater, as well as NetworkAdapterConfiguration but get an error regarding object not set to an instance.

    This is the code I am using to gain the information from the Win32_ComputerSystem class, I dont honestly know how to tie two classes together to get NetworkAdapter and the NetworkAdapterConfiguration and was hoping for some assistance.

    I am using the below code to obtain info from Win32 classes ComputerSystem, Bios, OperatingSystem, Processor and LogicalDisk with no issues.

    Try
    Dim query as ObjectQuery = New ObjectQuery("SELECT * FROM Win32_ComputerSystem")
    DIM Searcher As ManagementObjectSearcher = New ManagementObjectSearcher(scope, query)
    Dim moreturn as System.Management.MangementObjectCollection
    Dim mo as Management.ManagementObject
    moreturn = searcher.get
    
    For Each mo in moreturn
    Manufacturer = (mo("Manufacturer").ToString)
    Next
    Catch manuIssue as exception
    msgbox("Manufactured Issues: " & manIssues.Message)
    End Try
    

    Friday, December 8, 2017 12:55 PM

All replies

  • Use WMI Code Creator to generate WMI requests.


    • Marked as answer by Ryan Lashway Friday, December 8, 2017 3:04 PM
    • Unmarked as answer by Ryan Lashway Friday, December 8, 2017 3:29 PM
    Friday, December 8, 2017 1:29 PM
  • This generates the same thing I was able to generate, no IP address info on NICS i have static information on.

    Any clue?

    Friday, December 8, 2017 3:30 PM
  • If I add my main network adapter to get 1 result in the Select, I get my IP address :

    Dim searcher As New ManagementObjectSearcher(
            "root\CIMV2",
            "SELECT * FROM Win32_NetworkAdapterConfiguration where Description ='Qualcomm Atheros AR9287 Wireless Network Adapter'")
    
    For Each queryObj As ManagementObject In searcher.Get()
    
        Console.WriteLine("-----------------------------------")
        Console.WriteLine("Win32_NetworkAdapterConfiguration instance")
        Console.WriteLine("-----------------------------------")
    
        If queryObj("IPAddress") Is Nothing Then
            Console.WriteLine("IPAddress: {0}", queryObj("IPAddress"))
        Else
            Dim arrIPAddress As String()
            arrIPAddress = queryObj("IPAddress")
            For Each arrValue As String In arrIPAddress
                Console.WriteLine("IPAddress: {0}", arrValue)
            Next
        End If
    Next

    Friday, December 8, 2017 3:42 PM
  • I don't understand what you need.

    I assume this is for a remote system. You know the name of the remote system since you need it for the scope. So you use the same scope to get the Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration objects.

    You say don't "know how to tie two classes together" but I am not clear what you need help with.



    Sam Hobbs
    SimpleSamples.Info

    Saturday, December 9, 2017 1:40 AM