3

i want to get network interface name using device GUID.

i have a answer using "ipconfig /all" with parsing interface name

but "ipconfig /all" is very complex...

so i want to get like Getting friendly device names in python

but this only show usb driver..

i can find the GUID(actually i exalty don't know) followed code:

import netifaces as ni
x=ni.interfaces()
print x

this show like this ['{CDC97813-CC28-4260-BA1E-F0CE3081DEC7}']

i want to convert friendly device name like "local area connection"

Community
  • 1
  • 1
Somputer
  • 1,223
  • 2
  • 11
  • 20
  • sorry.. i'm confusing.. answer already exist in http://stackoverflow.com/questions/29913516/how-to-get-meaningful-network-interface-names-instead-of-guids-with-netifaces-un – Somputer May 03 '15 at 23:43
  • Feel free to close as a duplicate if you think so. At the bottom of your question should be a little link that says 'close'; then, click on 'duplicate of' and enter the URL of the question you think this is a duplicate of. – Nic May 04 '15 at 00:27
  • yeah.. but this answer also right – Somputer May 04 '15 at 02:14
  • It seems to be common practice here to close as duplicate anyway; I don't know the reasoning, but it's common enough that you should as well. – Nic May 04 '15 at 02:15

1 Answers1

4

Instead of ipconfig /all which is quite complex indeed, consider these much simpler, as far as output goes, commands:

>netsh interface show interface

Admin State    State          Type             Interface Name
-------------------------------------------------------------------------
Enabled        Connected      Dedicated        Wireless Network Connection
Enabled        Disconnected   Dedicated        Local Area Connection

or

>netsh interface ip show interfaces

Idx     Met         MTU          State                Name
---  ----------  ----------  ------------  ---------------------------
 13          25        1500  connected     Wireless Network Connection
 12           5        1500  disconnected  Local Area Connection

These should be almost trivial to parse for an interface name

Andrei
  • 55,890
  • 9
  • 87
  • 108
  • 1
    You can also use `wmic path Win32_NetworkAdapter where NetEnabled=True get /format:list`. The friendly name you want looks to be the `NetConnectionID` field. For the most reliable parsing I'd use the rawxml format. You can also use csv or just parse the list output. The `get` command can also take a comma-delimited list of fields to get instead of listing all fields. The GUID is one of the fields in case you want to filter on that in the `where` clause. See [`Win32_NetworkAdapter`](https://msdn.microsoft.com/en-us/library/aa394216) on MSDN. – Eryk Sun May 04 '15 at 02:27