I'm currently scheduling .bat
files using Windows Task Scheduler. However, I want to do this using the Command Prompt's schtasks
command. My batch file should run every five minutes and repeat its task every day.
Asked
Active
Viewed 3.6k times
15

Jules
- 1,677
- 1
- 19
- 25

Yosuva Arulanthu
- 1,444
- 4
- 18
- 32
1 Answers
23
I don't have much experience with .bat file (and maybe what I am about to write is nonsence), but I was wondering if a GOTO and a delay can resolve your problem.
:label
<do stuff>
SLEEP 300
GOTO label
LE: Ok, I found something that might help you:
schtasks /create /sc minute /mo 5 /tn "TaskName" /tr \\scripts\whatever.bat
This line should do the trick. For more information you can visit https://technet.microsoft.com/en-us/library/cc772785(v=ws.10).aspx

Cristian Marian
- 750
- 1
- 8
- 18
-
Added something to my answer. I hope it helps – Cristian Marian Mar 10 '15 at 07:00
-
instead of sleep 300 one would use timeout 300 > nul – Mike Q Sep 16 '21 at 02:37
-
schtasks /create /sc minute /mo 5 /tn "TaskName" /tr \\scripts\whatever.bat , That works a treat! Any advice on how I can turn it off? – Christopher Apr 22 '22 at 22:13
-
if you want to terminate the program that is run by the task, you can use: `schtasks /end /tn
`. If you want to remove the task altogether, you can use `schtasks /delete /tn – Cristian Marian Apr 27 '22 at 10:29`. Note that the latter doesn't stop a running program started by this task