|
SleepSeconds() [delay processing for the specified number of seconds].cmd |
The batch file sample below contains VBSCRIPT (is created at run time) imbedded into it.
The "VBS4CMD.VBS" script was used to turn the tested VBSCRIPT into the batch file code to create it. That code was further tweeked.
If you want to change the code its probably easiest to let the batch file create the code and comment out the deletion. You will then be able to test and improve the code before running it through "VBS4CMD.VBS" again.
Depending on your code you may want to create the VBS once and use many times or create each time.
The Code for: "SleepSeconds() [delay processing for the specified number of seconds].cmd" |
This is the example, a shortcut was installed to this code :
@echo off ::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ :: $Header: C:/DBAREIS/Projects.PVCS/Win32/ScriptingTipsAndTricks/EXAMPLE[cmd].SleepSeconds() [delay processing for the specified number of seconds].cmd.pvcs 1.0 11 Jul 2014 19:31:02 USER "Dennis" $ ::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ setlocal echo [%date% %time%] Creating the VBSCRIPT and executing it to wait for 3 seconds... call :SleepSeconds 3 echo [%date% %time%] Finished the 3 second wait... goto :EOF ::++++++++++++++++++++++++++++++++++++++++++ :SleepSeconds ::++++++++++++++++++++++++++++++++++++++++++ v14.073 set Wait4Seconds=%~1 set VBS=%TEMP%\SleepSeconds.VBS if exist "%VBS%" goto AlreadyExistsJustSleep echo Building the sleep VBSCRIPT: "%VBS%" echo on error resume next > "%VBS%" echo dim Seconds : Seconds = 10 : Seconds = wscript.arguments(0) >> "%VBS%" echo wscript.echo "Sleeping for " ^& Seconds ^& " seconds..." >> "%VBS%" echo wscript.sleep Seconds * 1000 >> "%VBS%" echo wscript.quit(0) >> "%VBS%" :AlreadyExistsJustSleep cscript.exe //NoLogo "%VBS%" %Wait4Seconds% goto :EOF
Please note that that I am not trying to show how great I am by producing batch files 9,000 characters long on one line that no one will understand or be able to debug when they go wrong. I am going out of my way to comment the code and make it verbose so beginners and advanced users will both benefit. I don't claim to be an expert that knows everything, if I'm wrong or make a mistake then please contact me and let me know :-)
![]() ![]() |
| ![]() ![]() |