Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
1  
What is the "right" interface in this scenario? –  Paul Nov 18 '11 at 3:42
add comment

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
share|improve this answer
add comment

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...

share|improve this answer
add comment

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

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx

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='0.0.0.0'") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE InterfaceIndex= " & intIndex)

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

share|improve this answer
add comment

This appears to solve the problem:

http://shadowbq.blogspot.com/2006/06/windump-finding-pcap-device-mapping.html

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.

share|improve this answer
    
Broken link – do you have a copy? Is it this one? –  slhck Nov 18 '11 at 17:45
    
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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