Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dnsservers.bat

(view source code of dnsservers.bat as plain text)

  1. @ECHO OFF
  2. SETLOCAL ENABLEDELAYEDEXPANSION
  3. IF "%~1"=="" (
  4. 	SET Node=%ComputerName%
  5. ) ELSE (
  6. 	SET Node=%~1
  7. )
  8.  
  9. ECHO.%Node% | FIND "?" >NUL && GOTO Syntax
  10.  
  11. 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 (
  12. 	ECHO.
  13. 	ECHO.%%A
  14. 	SET Counter=0
  15. 	FOR /F "delims={}" %%D IN ('ECHO.%%C') DO (
  16. 		FOR %%E IN (%%D) DO (
  17. 			SET /A Counter += 1
  18. 			ECHO DNS Server #!Counter!: %%~E
  19. 		)
  20. 	)
  21. )
  22. ENDLOCAL
  23. GOTO:EOF
  24.  
  25.  
  26. :Syntax
  27. ECHO.
  28. ECHO DNSServers.bat,  Version 1.00 for Windows XP Professional and later
  29. ECHO List DNS servers configured for each network adapter
  30. ECHO.
  31. ECHO Usage:  DNSSERVERS  [ computer ]
  32. ECHO.
  33. ECHO Where:  "computer"  is an optional remote computer name or IP address
  34. ECHO                     (default is the local computer)
  35. ECHO.
  36. ECHO Written by Rob van der Woude
  37. ECHO http://www.robvandereoude.com
  38.  
  39. IF "%OS%"=="Windows_NT" ENDLOCAL
  40. IF "%OS%"=="Windows_NT" COLOR 00
  41.  

page last modified: 2024-04-16; loaded in 0.0076 seconds