VB.Net: Getting a List of Networkconnections on a computer
From Wiki
With WMI it is pretty simple to do.
- Imports System.Management
- Module Module1
- Sub Main()
- GetNetworkInfo(My.Computer.Name)
- Console.ReadLine()
- End Sub
- Public Sub GetNetworkInfo(ByVal Machine As String)
- Dim scope As New System.Management.ManagementScope("\\" + Machine + "\root\cimv2")
- scope.Connect()
- Dim objectQuery As New ObjectQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId IS NOT NULL")
- Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
- Dim os As ManagementObject
- Dim moColl As ManagementObjectCollection = searcher.Get()
- Dim _list As String = ""
- For Each os In moColl
- Console.WriteLine(os("NetConnectionId"))
- Next os
- End Sub
- End Module
With this as a result (on my computer)
Local Area Connection VMware Network Adapter VMnet1 VMware Network Adapter VMnet8


