I'm developing an application that provides a UI to windump, the packet sniffer. Windump has a "-D" parameter that lists all network interfaces it can find, and then you can specify which interface to listen on.

However, I'd like to avoid forcing the user to manually configure which interface to listen on. On Unix, I can obtain the right network interface (en0, en1, etc.) via a call to ifconfig and some parsing of the output, but I cannot locate any equivalent Windows API or command that can yield similar information—ipconfig doesn't seem to obtain this data.

Can anyone suggest either a Windows command-line tool or an API that can be called via VBScript to obtain this data so that I don't have to present the user with a dialog in my GUI telling them to select the right interface?

  • 1
    What is the "right" interface in this scenario?
    – Paul
    Nov 18, 2011 at 3:42

4 Answers 4


This command will provide a list of interfaces, with the connected or disconnected status:

c:\>netsh interface show interface

Admin State    State          Type             Interface Name
Enabled        Connected      Dedicated        Local Area Connection

you can check more information about the connection using ipconfig /all. there are some other utilities are also available like netsh and netstat for other purpose..

enter image description here

If you are looking as coding perspective then you must look for some Windows API code from which you can create your own api that will help you get information on windows operating system.. you can use windows api or some created api in .net.. here is more information about these; if you are able to program for this..

here is some code snippet to get the all information about the network.. check these links. may be they can be included in vbscript. link1 link2 link3 link4

hope this help you...


This appears to solve the problem:


It's a VBS script that queries the active network interface and converts it into a format suitable for passing to windup.exe as a parameter.


You don't need make a new API. Use the WMI class from VBScript.


By far the best way to do this is not to enumerate the NICs first. Rather parse the routing table. It is the same mechanism that the computer uses to decide where to route packets to the Internet, which I assume is your main goal.

An example

Set Host = "."  
Set WMI = GetObject("winmgmts:\\" & Host & "\root\CIMV2")
Set intIndex = WMI.ExecQuery("SELECT InterfaceIndex FROM Win32_IP4RouteTable WHERE Destination=''")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE InterfaceIndex= " & intIndex) 

This will return any adapters at the top of the routing table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.