Page 1 of 1

Pause for n seconds

Posted: 16 Mar 2011 17:10
by scienceguru1.bat
Does anyone know of a way to have the script pause for n seconds? thanks.

Re: Pause for n seconds

Posted: 16 Mar 2011 17:16
by aGerman
Often used: PINGing the own machine:

Code: Select all

ping -n 11 localhost>nul

... for a delay of 10 seconds (one more pings than seconds).

Regards
aGerman

Re: Pause for n seconds

Posted: 16 Mar 2011 17:18
by scienceguru1.bat
How do the variables work?

Re: Pause for n seconds

Posted: 16 Mar 2011 17:21
by aGerman
Don't get it. There is no variable :?

Re: Pause for n seconds

Posted: 16 Mar 2011 17:50
by scienceguru1.bat
How to adjust the wait.

Re: Pause for n seconds

Posted: 16 Mar 2011 18:23
by aGerman
As I wrote: "one more pings than seconds".
number of pings = number of seconds + 1

Code: Select all

@echo off &setlocal
set /p "x=Enter the number of seconds: "

set /a x+=1

echo delay start %time%
ping -n %x% localhost>nul
echo delay end %time%

pause>nul

It takes approx. 200ms to call ping.exe, thats why the delay is a little longer.

Regards
aGerman

Re: Pause for n seconds

Posted: 17 Mar 2011 09:53
by !k

Re: Pause for n seconds

Posted: 17 Mar 2011 13:36
by scienceguru1.bat
thanks, everyone. i'll test it when i can get on my computer. it should work.

Re: Pause for n seconds

Posted: 17 Mar 2011 17:50
by scienceguru1.bat
Thanks everyone, it works :D