I am trying to create a scheduled task from the command line. I need the task to run every day at 7:05pm and run for a maximum duration of 1 hour. Just once until the next day.
Here is my command:
schtasks.exe /create /ru DeployUser /rp '********' /tn "Run All Tasks" /tr "'tasks.exe RunAllTasks'" /sc DAILY /st 19:05:00 /F /du 01:00
That command produces the following trigger.
At 7:05 PM every day – After triggered, repeat every 10 minutes for a duration of 1 hour.
The repeating every 10 minutes is not desirable and I do not see where in my command this was requested. Maybe it is a default for using duration, is there a way to get rid of it?
Best Answer
Having the same problem here. I've found it is a default setting when you use either the /ET or /DU switch.
Frustratingly I haven't yet figured out how to stop the repeat applying when using either of the switches.
Here's the bit from the technet that I found it in:
https://technet.microsoft.com/en-us/library/cc725744(v=ws.11).aspx#BKMK_change
Doesn't answer the question but hopefully provides a bit of clarity.
The closest suggestion I've found to an answer is to create a second task that ends the first one: schtasks /end /tn TaskName