JSI Tip 8270. How do I retrieve an interface {GUID}?

In order to be able to accommodate multiple network adapters, many networking settings are located in the registry under an interface \{GUID\} (Globally Unique IDentifier), such as:

I have scripted InterfaceGUID.bat to retrieve the \{GUID\} based upon a connection name that you specify, such as Local Area Connection.

The syntax for using InterfaceGUID.bat is:

Call InterfaceGUID Name GUID

Where Name is the connection name, and GUID is a call directed environment variable that will contain the \{GUID\}, or none if the connection name cannot be found.

NOTE: InterfaceGUID.bat uses REG.EXE built into Windows XP, Windows Server 2003, and newer, or from the Windows 2000 Support Tools.

InterfaceGUID.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax InterfaceGUID Name GUID&goto :EOF
set name=%1
set GUID=none
set key="HKLM\SYSTEM\CurrentControlSet\Control\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318\}"
for /f "Tokens=*" %%i in ('reg query %key% /s^|Findstr /I /L /C:"\}\Connection"') do (
 call :fndname "%%i"
endlocal&set %2=%GUID%
goto :EOF
set conkey=%1
set conkey=%conkey:HKEY_LOCAL_MACHINE=HKLM%
for /f "Tokens=1,2*" %%a in ('reg query %conkey% /v Name^|findstr /I /L /C:%name%') do (
 call :setGUID
goto :EOF
set GUID=%conkey:"HKLM\SYSTEM\CurrentControlSet\Control\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318\}\=%
set GUID=%GUID:\Connection"=%

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.