Page 1 of 1

Need to create a 60 minutes delay in my DOS script

Posted: 23 Dec 2009 10:54
by tropics
Hi everyone

I know I can delay from 5 to 99 seconds using the command line below:

TYPE NUL | CHOICE.COM /N /CY /TY,5 >NUL --> it delays for 5 secs

But I am not sure if it is feasible by any other means, to delay as long as 60 minutes.

I'd appreciate if anyone who has had such request before, could put me in the right direction.

Thank you in advance

tropics

Posted: 23 Dec 2009 12:10
by avery_larry
ping -w 999 -n 3601 127.0.0.1 >nul 2>nul

Posted: 23 Dec 2009 12:25
by tropics
Hi avery_larry

Could you explain why ping and what the args mean? I ran it by first I replaced 999 with 5 and the prompt didn't come back so, I had to break it with ctl C

Thanks

Tropics

Posted: 23 Dec 2009 13:28
by !k
tropics wrote:why ping and what the args mean?
ping /?
tropics wrote:I replaced 999 with 5...
If you wanted a delay for 5 minutes, you had to write it

Code: Select all

ping -w 1000 -n 300 127.0.0.1 >nul

Another way to delay using VBS in batch

Code: Select all

:: begin of batch
echo wscript.sleep wscript.arguments(0)>sleep.vbs
:: ... some code ...
:: delay 1 sec
cscript sleep.vbs 1000 > nul
:: ... some code ...
:: delay 5 min
cscript sleep.vbs 300000 > nul
:: ... some code ...
:: delay 60 min
cscript sleep.vbs 3600000 > nul
:: ... some code ...
del sleep.vbs
:: end of batch

Posted: 24 Dec 2009 10:15
by tropics
I decided to use the sleep command in my script since it is going to be running on a server and I have windows resource tool kit installed on the server.

Thanks guys!

Posted: 17 Jan 2010 21:31
by viroid
Windows 2003 and above all have a command called WAITFOR that can be used to pause for up to 99999 seconds. Its actually used to have server1 wait for a process on server2 to finish, once server2 finishes its process, it broadcast the 'signal' across the network to server1 and then server1 begins/continues processing.

The syntax when using as a pause is

WAITFOR Nothing /t 3600

where "Nothing" is the signal to waitfor, and /t xxx is how long the server will wait for that command.

...v

Posted: 18 Jan 2010 17:35
by adz
I always use:

ping localhost -n * >nul

* = the seconds you want to delay

Posted: 19 Jan 2010 14:31
by avery_larry
adz wrote:I always use:

ping localhost -n * >nul

* = the seconds you want to delay


Technically, * should be the number of seconds you want to delay PLUS ONE.

Posted: 19 Jan 2010 14:46
by adz
avery_larry wrote:
adz wrote:I always use:

ping localhost -n * >nul

* = the seconds you want to delay


Technically, * should be the number of seconds you want to delay PLUS ONE.


Ok, on second thought, I saw you using that in one of your examples but never gave attention to it. Thanks for this tip. :)

Re: Need to create a 60 minutes delay in my DOS script

Posted: 22 Jan 2010 10:13
by avery_larry
It's not like it's very accurate anyway. :shock: