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

Jerold Schulman

July 19, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today


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:

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesNetBTParametersInterfacesTcpip_{GUID}HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesPSchedParametersAdapters\{GUID}HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParametersAdapters\{GUID}HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParametersDNSRegisteredAdapters\{GUID}HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices\{GUID}ParametersTcpip.

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 offif {%2}=={} @echo Syntax InterfaceGUID Name GUID&goto :EOFsetlocalset name=%1set GUID=noneset key="HKLMSYSTEMCurrentControlSetControlNetwork\{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:fndnameset conkey=%1set 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:setGUIDset GUID=%conkey:"HKLMSYSTEMCurrentControlSetControlNetwork\{4D36E972-E325-11CE-BFC1-08002BE10318}=%set GUID=%GUID:Connection"=%



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like