Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for listica.bat

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

  1. @ECHO OFF
  2. :: Check Windows version: NT 4 or later required
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: No command line arguments necessary
  6. IF NOT "%~1"=="" GOTO Syntax
  7.  
  8. :: Enable delayed variable expansion
  9. SETLOCAL ENABLEDELAYEDEXPANSION
  10.  
  11. :: Initialize variable
  12. SET ica=
  13.  
  14. :: Store list of IP addresses in single environment variable
  15. FOR /F "skip=4 tokens=*" %%A IN ('NSLOOKUP.EXE ica') DO SET ica=!ica! %%A
  16.  
  17. :: Check if any address was found
  18. IF NOT DEFINED ica GOTO Syntax
  19.  
  20. :: Display a header -- cannot be redirected
  21. > CON ECHO.
  22. > CON ECHO IP addresses for ica:
  23. > CON ECHO.
  24.  
  25. :: Display the resulting IP addresses -- can be redirected
  26. (FOR %%A IN (%ica%) DO @ECHO.    %%A) | SORT.EXE | FIND.EXE "."
  27.  
  28. :: Done
  29. ENDLOCAL
  30. GOTO:EOF
  31.  
  32.  
  33. :Syntax
  34. ECHO.
  35. ECHO ListICA.bat,  Version 1.00 for Windows NT 4 and later
  36. ECHO List all IP addresses for Citrix' "ICA" DNS round robin alias
  37. ECHO.
  38. ECHO Usage:  LISTICA
  39. ECHO.
  40. ECHO Written by Rob van der Woude
  41. ECHO http://www.robvanderwoude.com
  42.  

page last uploaded: 2017-04-06, 13:33