Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for listdhcp.bat

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

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Synatx
  3. IF NOT "%~1"=="" IF /I NOT "%~1"=="/NH" GOTO Syntax
  4.  
  5. SETLOCAL ENABLEDELAYEDEXPANSION
  6. IF /I NOT "%~1"=="/NH" ECHO DHCP Server	Network adapter
  7. FOR /F "tokens=*" %%A IN ('NETSH Diag Show DHCP') DO (
  8. 	FOR /F "tokens=2* delims=[]" %%B IN ("%%~A") DO (
  9. 		SET Adapter=%%C
  10. 	)
  11. 	FOR /F "tokens=2 delims==" %%B IN ("%%~A") DO (
  12. 		SET DHCPServer=%%B
  13. 		ECHO.!DHCPServer:~1!	!Adapter:~1!
  14. 		SET Adapter=
  15. 	)
  16. )
  17. ENDLOCAL
  18. GOTO:EOF
  19.  
  20.  
  21. :Syntax
  22. ECHO.
  23. ECHO ListDHCP.bat,  Version 1.00 for Windows XP and later
  24. ECHO List DHCP servers for all network adapters
  25. ECHO.
  26. ECHO Usage:  LISTDHCP  [ /NH ]
  27. ECHO.
  28. ECHO Where:  /NH  (No Header) prevents display of table header
  29. ECHO.
  30. ECHO Written by Rob van der Woude
  31. ECHO http://www.robvanderwoude.com
  32.  
  33. IF "%OS%"=="Windows_NT" COLOR 00
  34.  

page last uploaded: 2017-07-06, 12:37