batch file with timer

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
joost
Posts: 1
Joined: 13 Feb 2014 04:27

batch file with timer

#1 Post by joost » 13 Feb 2014 04:36

I must make a batchfile.
I must run a program every 5 minuts.
we can help me with a example.

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: batch file with timer

#2 Post by ShadowThief » 13 Feb 2014 08:40

You'd be better off using the Windows Task Scheduler.
http://stackoverflow.com/questions/4249 ... -x-minutes

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: batch file with timer

#3 Post by Samir » 27 Feb 2014 10:58

I use this piece of code to execute something daily:

Code: Select all

:START
PING -n 60 127.0.0.1 > NUL
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"=="10:00" GOTO START

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: batch file with timer

#4 Post by Squashman » 27 Feb 2014 11:29

Samir wrote:I use this piece of code to execute something daily:

Code: Select all

:START
PING -n 60 127.0.0.1 > NUL
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"=="10:00" GOTO START

How does this help run the batch file every 5 minutes?
Again Windows Task Scheduler has the option to repeat a task every X minutes.

stobal
Posts: 1
Joined: 09 Mar 2014 14:25

Re: batch file with timer

#5 Post by stobal » 09 Mar 2014 14:40

Not quite tidy DOS, but I use the tiny program sleep.exe as loop timer:

:loop
myprogram.exe
sleep 800
goto loop

This starts the program "myprogram.exe" every 800 seconds. To be precise, ist starts the program again 800 second after the last execution ended. Of course, the sleep.exe and myptogram.exe must be within path or in the same directory with the batch file.
Sleep.exe can be downloaded from internet.

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: batch file with timer

#6 Post by Samir » 27 Mar 2014 08:24

Squashman wrote:
Samir wrote:I use this piece of code to execute something daily:

Code: Select all

:START
PING -n 60 127.0.0.1 > NUL
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"=="10:00" GOTO START

How does this help run the batch file every 5 minutes?
Again Windows Task Scheduler has the option to repeat a task every X minutes.
I think I pasted the wrong code. I've got a piece that I use that will automatically execute the loop every 15m.

The benefit over task scheduler is that no admin rights are needed, and nothing can go wrong with it like a rogue application taking down windows crap.

Post Reply