I must make a batchfile.
I must run a program every 5 minuts.
we can help me with a example.
batch file with timer
Moderator: DosItHelp
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: batch file with timer
You'd be better off using the Windows Task Scheduler.
http://stackoverflow.com/questions/4249 ... -x-minutes
http://stackoverflow.com/questions/4249 ... -x-minutes
Re: batch file with timer
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
Re: batch file with timer
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.
Re: batch file with timer
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.
: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.
Re: batch file with timer
I think I pasted the wrong code. I've got a piece that I use that will automatically execute the loop every 15m.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.
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.