Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for wanip.bat

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

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. :: Check command line arguments
  5. IF NOT  "%~1"==""           GOTO Syntax
  6. :: Check if WGET is available
  7. WGET.EXE -V >NUL 2>&1 ||    GOTO Syntax
  8.  
  9. :: Display a header
  10. ECHO My WAN Connection:
  11. ECHO.==================
  12. :: Use WGET to retrieve your own WAN IP address from a
  13. :: web page, and NSLOOPKUP to get the host name as well
  14. FOR /F %%A IN ('WGET.EXE -q -O- --no-check-certificate https://www.robvanderwoude.com/wanip.php 2^>NUL') DO (
  15. 	NSLOOKUP.EXE %%A 2>NUL | MORE /E +3
  16. )
  17.  
  18. :: Terminate
  19. GOTO:EOF
  20.  
  21.  
  22. :Syntax
  23. ECHO.
  24. ECHO WANIP.bat,  Version 4.01 for Windows 7 and later
  25. ECHO Display your WAN connection's IP address and host name
  26. ECHO.
  27. ECHO Usage:  WANIP
  28. ECHO.
  29. ECHO Note:   This batch file uses WGET, available at
  30. ECHO         http://www.gnu.org/software/wget/wget.html
  31. ECHO.
  32. ECHO Idea: Gregg Dotoli
  33. ECHO Written by Rob van der Woude
  34. ECHO https://www.robvanderwoude.com
  35.  

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