JSI Tip 9655. How can I locate the registry key for the TCPIP service parameters interface for my LAN?

If you wanted to configure the TCP/IP parameters for your LAN that are located at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\\{ID for Adapter\} you would need to locate the \{ID for Adapter\} key.

NOTE: Some other TCP/IP registry values are located using How do I retrieve an interface \{GUID\}?.

I have scripted TCPIFKEY.bat to locate the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\\{ID for Adapter\} key for your LAN.

The syntax for using TCPIFKEY.bat is:

TCPIFKEY Mask Key

Where:

MasK is the IP address string that uniquely identifies your LAN, like 192.168.0. or 192.168.

Key  is a  call directed environment variable that will contain the full key.
     If the key is not found, Key will be set to NONE.
NOTE: TCPIFKEY.bat uses REG.EXE, built into Windows XP and Windows Server 2003, or REG.EXE from the Windows 2000 Support Tools on the CD-ROM, which must be available in your PATH.

TCPIFKEY.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax TCPIFKEY Mask key&goto :EOF
setlocal ENABLEDELAYEDEXPANSION
set mask=%1
set mask=%mask:"=%
set qry=reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces /s
Set OK=N
set key=NONE
for /f "Tokens=*" %%a in ('%qry%') do (
 set work=%%a
 if "!OK!" NEQ "Y" if "!work:~0,18!" EQU "HKEY_LOCAL_MACHINE" set OK=X&set key=%%a
 for /f "Tokens=*" %%x in ('@echo %%a^|FIND "%mask%"') do (
   if "!OK!" EQU "X" set OK=Y
 )
)
if "%OK%" NEQ "Y" set key=NONE
endlocal&set %2=%key%



Hide comments

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