Function to get interface user-defined name?

x13

Nov 9, 2016
76
1
Netherlands
Hello all.

Maybe I'm missing something, but I can't figure it out...

I'm trying to retrieve the interface names that I assigned.
(on Win7, Network connections, and F2 on a specific adapter to rename it)

If I use %@IPNAMEN[n], then I get names like :

{DAE8366E-2855-4154-A56F-3957062BEE1F}
{F6F7C705-D880-4C35-A2B0-CD6714B587E1}
{540FD87B-6A0D-411C-BFDE-DEEF77FDD6E6}

Those are technically correct, but not the names I'm looking for.

If I use %@IPALIASES[n], I get an empty string.

This is also correct, since in Windows, an alias is actually a different IP config for the same adapter, so it's not just limited to the interface name.

If I use %@IPDESC[n], I get this :

Realtek PCIe GBE Family Controller
DisplayLink Ethernet
Qualcomm Atheros QCA9565 802.11b/g/n WiFi Adapter

Again, also true but not the names I'm looking for.

So short of using %@EXECSTR[NETSH...], if there a built-in function to get me this info?

Thanks.
x13
 
Aug 3, 2016
376
9
Netherlands
Not completely sure, but my guess is you want information about network *connections* instead of information about *adapters* (physical/virtual NIC's).

Network connections include beside an adapter also the bindings with network protocol and network client.

I never used the %@IP functions before, but after a quick glance I could not find *connection* related functions.
You could read them from the registry, though:

Code:
echo %@regquery[HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%@IPNAMEN[n]\Connection\Name]

Local Area Connection

Where {4D36E972-E325-11CE-BFC1-08002BE10318} is the GUID of the Net Class (fixed Microsoft GUID)
and [n] is the index of the adapter. In my case it was [0]



Or use a %@WMI query. For inspiration:
Code:
WMIC.exe NIC | view
 

x13

Nov 9, 2016
76
1
Netherlands
Not completely sure, but my guess is you want information about network *connections* instead of information about *adapters* (physical/virtual NIC's).

Network connections include beside an adapter also the bindings with network protocol and network client.

I never used the %@IP functions before, but after a quick glance I could not find *connection* related functions.
You could read them from the registry, though:

Code:
echo %@regquery[HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%@IPNAMEN[n]\Connection\Name]

Local Area Connection

Where {4D36E972-E325-11CE-BFC1-08002BE10318} is the GUID of the Net Class (fixed Microsoft GUID)
and [n] is the index of the adapter. In my case it was [0]



Or use a %@WMI query. For inspiration:
Code:
WMIC.exe NIC | view
Of
 

x13

Nov 9, 2016
76
1
Netherlands
Natuuuuurlijk!

How silly of me.

So the missing function can be added thus :

FUNCTION IPCONNECTION=`%@REGQUERY[HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%@IPNAMEN[%1]\Connection\Name]`

DO x=0 TO %_IPADAPTERS (ECHO %x = %@IPCONNECTION[%x])
0 = BT_PAN
1 = LAN
2 = DLINK
3 = WLAN
4 = TAP
5 = VMnet1
6 = VMnet8

Works a treat! Thanks.


I actually wanted to write this piece of code for a related problem...
One of my BTMs checks the connection status of a given interface using NETSH (via %@EXECTSTR).

But for an unknown reason, the one I called "WLAN" is half-no longer recognised by NETSH (though it's in the registry and also appears in the network interfaces correctly). I get this result also using NETSH directly btw.

This is what I mean :

NETSH INTERFACE SHOW INTERFACE NAME=WLAN

WLAN
Type: Dedicated
Administrative state: Enabled
Connect state: Disconnected



NETSH INTERFACE IP SHOW INTERFACE WLAN
Element not found

Whereas another user-defined interface shows normal info.

NETSH INTERFACE IP SHOW INTERFACE LAN

Interface LAN Parameters
----------------------------------------------
IfLuid : ethernet_30
IfIndex : 28
State : connected
Metric : 10
Link MTU : 1500 bytes
[...]


I know this has nothing to do with TCC, but as long as we're on the subject, perhaps someone can tell me where to look.
It's most likely a stale registry entry, but I don't want to mess arround too much with those as it can f*%-up the network config.
I learned my lesson the last time.

Thanks.

Mark/x13
 
Aug 3, 2016
376
9
Netherlands
For some strange reason WLAN has it's own NETSH "interface".
Try:

Code:
NETSH WLAN Show Interfaces

(Can't test this right now, but it *should* give you a connection status)
 
Aug 3, 2016
376
9
Netherlands
NETSH INTERFACE IP SHOW INTERFACE WLAN works here .. ("WLAN" = "Wi-Fi" in my case)

First thing that comes to mind is that the WLAN network isn't managed through Windows, but by a utility provided by the hardware manufacturer (most laptop manufacturers have their own utility). This might bypass the Windows mechanism.
 
Similar threads
Thread starter Title Forum Replies Date
T Fixed Function @timer[] does not work as required Support 6
vefatica Documentation Function parameters Support 0
Jay Sage Documentation Function @DRIVE Missing in Help Lists Support 0
Joe Caverly How to? Get name of current LIBRARY function? Support 4
x13 WeekNum function? Support 3
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
cgunhouse Ctrl-C from within a library function Support 6
C email[string] function Support 10
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
Dick Johnson Using the @instr function Support 5
vefatica '}' in a library function? Support 3
D Can the argument to RETURN be a function expansion? Support 3
J Trouble with @full[] function. Support 3
Fross Quick Function Question Support 17
vefatica Quoting @Function parameters? Support 0
Joe Caverly Debugging a LIBRARY function Support 10
Steve Pitts Documentation @CAPI function summary Support 0
x13 %x$ in function Support 3
thorntonpg @eval function, interesting results any explanation? Support 3
vefatica Fixed Help @FUNCTION, missing paragraph Support 8
Mordachai Variable followed by function constantly failing... Support 5
nickles Call a complex function Support 13
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
R Function #IDOW returns only 2 characters Support 10
T scrput `` in alias or function Support 2
S International characters - TYPE vs %@LINE function Support 5
JohnQSmith WAD @REPEAT function Support 15
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
R In addition to ALIAS /Z and FUNCTION /Z, HISTORY /Z? Support 1
A pdir function usage Support 3
nikbackm FUNCTION with variable number of arguments Support 17
S %@REGQUERY function Support 1
Dan Glynhampton Documentation v15 help: Error on @TRIMALL function page Support 0
M Why doesn't this @Field function work? Support 0
fpefpe How to? user function Support 1
M Why is this function getting these results in these circumstances? Support 6
A WAD function return values with parentheses prevent evaluation of additional functions Support 31
M Just an out-of-curiosity question the List command vs. the @Lines function... Support 13
M How to? Just verification for what I think I know regarding "Function"... Support 4
Frank How to? need help with "function" Support 10
Joe Caverly How to? Function Key With INPUT Support 5
M How to? "Function" and "%[xxx]" Support 7
M Kind of a out-of-curiosity question re. the "Function" command... Support 5
M Simple question about "Function" command... Support 4
M Just a curiosity question related to the "Function" command... Support 2
C not sure of windows registry function use Support 2
Phileosophos The @urlencode function doesn't seem to URL encode Support 16
J issue to have "if" inside function Support 3
Frank is the search-function in VIEW working? Support 2
M Weird @Index function result... Support 7

Similar threads