Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for pmslpw9x.bat

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

  1. @ECHO OFF
  2. :: Check if a timeout period is specified
  3. IF "%1"=="" GOTO Syntax
  4.  
  5. :: Filter out slashes, they make the IF command crash
  6. ECHO.%1 | FIND "/" >NUL
  7. IF NOT ERRORLEVEL 1 GOTO Syntax
  8.  
  9. :: Check for a non-existent IP address
  10. :: Note: this causes a small extra delay!
  11. IF "%NonExist%"=="" SET NonExist=10.255.255.254
  12. PING %NonExist% -n 1 -w 100 | FIND "TTL=" >NUL
  13. IF ERRORLEVEL 1 GOTO Delay
  14. SET NonExist=1.1.1.1
  15. PING %NonExist% -n 1 -w 100 | FIND "TTL=" >NUL
  16. IF NOT ERRORLEVEL 1 GOTO NoNonExist
  17.  
  18. :Delay
  19. :: Use PING time-outs to create the delay
  20. PING %NonExist% -n 1 -w %1000 >NUL
  21.  
  22. :: Show online help on errors
  23. IF ERRORLEVEL 1 GOTO Syntax
  24.  
  25. :: Done
  26. GOTO End
  27.  
  28. :NoNonExist
  29. ECHO.
  30. ECHO This batch file needs an invalid IP address to function
  31. ECHO correctly.
  32. ECHO Please specify an invalid IP address in an environment
  33. ECHO variable named NonExist and run this batch file again.
  34.  
  35. :Syntax
  36. ECHO.
  37. ECHO PMSlpW9x.bat
  38. ECHO Poor Man's SLEEP utility,  Version 2.10 for Windows 95 / 98
  39. ECHO Wait for a specified number of seconds.
  40. ECHO.
  41. ECHO Written by Rob van der Woude
  42. ECHO http://www.robvanderwoude.com
  43. ECHO Corrected and improved by Todd Renzema and Greg Hassler
  44. ECHO.
  45. ECHO Usage:    CALL PMSLPW9X nn
  46. ECHO.
  47. ECHO Where:    nn is the number of seconds to wait
  48. ECHO.
  49. ECHO Example:  CALL PMSLPW9X 10
  50. ECHO           will wait for 10 seconds
  51. ECHO.
  52. ECHO Note:     Due to "overhead" the actual delay may
  53. ECHO           prove to be up to a second longer
  54.  
  55. :End
  56.  

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