(view source code of dnsservers.bat as plain text)
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
IF "%~1"=="" (
SET Node=%ComputerName%
) ELSE (
SET Node=%~1
)
ECHO.%Node% | FIND "?" >NUL && GOTO Syntax
FOR /F "skip=1 tokens=2,3* delims=," %%A IN ('WMIC.EXE /Node:"%Node%" Path Win32_NetworkAdapterConfiguration Get Description^,DNSHostName^,DNSServerSearchOrder /Format:CSV ^| FIND "," ^| FIND /V ",,"') DO (
ECHO.
ECHO.%%A
SET Counter=0
FOR /F "delims={}" %%D IN ('ECHO.%%C') DO (
FOR %%E IN (%%D) DO (
SET /A Counter += 1
ECHO DNS Server #!Counter!: %%~E
)
)
)
ENDLOCAL
GOTO:EOF
:Syntax
ECHO.
ECHO DNSServers.bat, Version 1.00 for Windows XP Professional and later
ECHO List DNS servers configured for each network adapter
ECHO.
ECHO Usage: DNSSERVERS [ computer ]
ECHO.
ECHO Where: "computer" is an optional remote computer name or IP address
ECHO (default is the local computer)
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvandereoude.com
IF "%OS%"=="Windows_NT" ENDLOCAL
IF "%OS%"=="Windows_NT" COLOR 00
page last modified: 2024-04-16; loaded in 0.0076 seconds