Skip navigation

JSI Tip 9859. How can I locate the Registry key that contains the specific TCP/IP settings for my network adapter(s)?

Using wntipcfg.exe in batch mode, I have scripted TCPIPNIC.bat to return the registry key that contains the TCP/IP settings for my network adapter(s).

The syntax for using TCPIPNIC.bat is:

For /f "Tokens=*" %%a in ('TCPIPNIC') do (
 set key=%%a
 ...
 ...
)

Example:

@echo off
setlocal ENABLEDELAYEDEXPANSION
For /f "Tokens=*" %%a in ('TCPIPNIC') do (
 for /f "Skip=2 Tokens=1,2*" %%x in ('REG QUERY %%a') do (
 if "%%y" EQU "" set key=%%x
 if "%%y" NEQ "" @echo "!key!","%%x","%%y","%%z"
 )
)
endlocal
TCPIPNIC.bat contains:
@echo off
setlocal
set wrk="%TEMP%\TCPIPNIC_RANDOM.TMP"
wntipcfg /ALL /BATCH %wrk%
set key=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces
for /f "Tokens=1-3 Delims=: " %%u in ('type %wrk%^|find "Ethernet"^|find "adapter"') do (
 for /f "Tokens=*" %%a in ('REG QUERY "%key%\%%w"^|find /i "%key%"') do (
  @echo %%a
 )
)
del /q %wrk%
endlocal


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