Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for pmsleep.bat

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

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: Check if a valid timeout period is specified
  6. IF     "%~1"=="" GOTO Syntax
  7. IF NOT "%~2"=="" GOTO Syntax
  8. ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL || GOTO Syntax
  9. IF %~1 LSS    1 GOTO Syntax
  10. IF %~1 GTR 3600 GOTO Syntax
  11.  
  12. :: Use local variable
  13. SETLOCAL
  14.  
  15. :: Add 1 second for IPv4
  16. SET /A seconds = %1 + 1
  17.  
  18. :: The actual command: try IPv4 first, if that fails try IPv6
  19. PING -n %seconds% 127.0.0.1 >NUL 2>&1 || PING -n %1 ::1 >NUL 2>&1
  20.  
  21. :: Done
  22. ENDLOCAL
  23. GOTO:EOF
  24.  
  25.  
  26. :Syntax
  27. ECHO.
  28. ECHO PMSleep.bat
  29. ECHO Poor Man's SLEEP utility,  Version 3.00 for Windows NT 4 and later.
  30. ECHO Wait for a specified number of seconds.
  31. ECHO.
  32. ECHO Usage:  CALL  PMSLEEP  seconds
  33. ECHO.
  34. ECHO Where:        seconds  is the number of seconds to wait (1..3600)
  35. ECHO.
  36. ECHO Notes:  The script uses PING for the delay, so an IP stack is required.
  37. ECHO         The delay time will not be very accurate.
  38. ECHO.
  39. ECHO Written by Rob van der Woude
  40. ECHO http://www.robvanderwoude.com
  41.  
  42. IF "%OS%"=="Windows_NT" EXIT /B 1
  43.  

page last uploaded: 2017-08-21, 14:26