Need to create a 60 minutes delay in my DOS script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tropics
Posts: 3
Joined: 09 Nov 2009 13:38

Need to create a 60 minutes delay in my DOS script

#1 Post by tropics » 23 Dec 2009 10:54

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

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 23 Dec 2009 12:10

ping -w 999 -n 3601 127.0.0.1 >nul 2>nul

tropics
Posts: 3
Joined: 09 Nov 2009 13:38

#3 Post by tropics » 23 Dec 2009 12:25

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

#4 Post by !k » 23 Dec 2009 13:28

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

tropics
Posts: 3
Joined: 09 Nov 2009 13:38

#5 Post by tropics » 24 Dec 2009 10:15

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!

viroid
Posts: 8
Joined: 04 Jan 2010 15:49

#6 Post by viroid » 17 Jan 2010 21:31

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

adz
Posts: 4
Joined: 18 Jan 2010 17:20
Location: Hollands

#7 Post by adz » 18 Jan 2010 17:35

I always use:

ping localhost -n * >nul

* = the seconds you want to delay

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#8 Post by avery_larry » 19 Jan 2010 14:31

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.

adz
Posts: 4
Joined: 18 Jan 2010 17:20
Location: Hollands

#9 Post by adz » 19 Jan 2010 14:46

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. :)

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

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

#10 Post by avery_larry » 22 Jan 2010 10:13

It's not like it's very accurate anyway. :shock:

Post Reply