Computing.Net > Forums > Programming > Batch file interval timer

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file interval timer

Reply to Message Icon

Name: DeeJay
Date: December 19, 2004 at 01:52:03 Pacific
OS: Windows XP Professional
CPU/Ram: P4 512MB RAM, 2.6GHz
Comment:

Hi,

I'm trying to write a batch file that asks for a number and then uses an external program (which inserts a delay into the file) to delay for that number of seconds. Each time the set amount of time is up, it displays a message and then starts the timer again. However I can't get it to work.

BTW, the external program (called SLEEP.EXE) has to be in the same directory as the batch file to work. You can download it from here.

Here is what I have so far:

***IntervalTimer.bat***
@ECHO OFF
:credits
ECHO Interval Timer
ECHO.
ECHO uses the "SLEEP.EXE" program, downloadable from
ECHO.
ECHO http://www.computerhope.com/
SLEEP 5

:settimer
ECHO Set the respawn time for the Nature rune chest.
set choice=
set /p choice=Enter the respawn time for the Nature rune chest in seconds.
if not '%choice%'==" set choice=%choice:~0,1%
if '%choice%'>'100' goto timer
if '%choice%'<'100' goto settimer

ECHO "%choice" is not valid. Please try again.
ECHO.
goto settimer

:timer
sleep %choice%
goto timer2

:timer2
goto timer

:end


Thankyou for your help.

---
DeeJay



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: December 19, 2004 at 02:41:05 Pacific
Reply:

David,

Ignoring all the prompting for now, you can use ping as a timer. And it's already in the standard path.

Like this:

ping 127.0.0.1 -n #

where # is the number of seconds.

What's not working with what you have?


M2

Mechanix2@Golden-Triangle.com


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file interval timer

Batch file shutdown timer www.computing.net/answers/programming/batch-file-shutdown-timer/13959.html

Batch file help www.computing.net/answers/programming/batch-file-help/12261.html

Telnet Batch File www.computing.net/answers/programming/telnet-batch-file/13963.html