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" ) ) endlocalTCPIPNIC.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
0 comments
Hide comments