2

How to schedule a task to run every 10 minutes, from 8:00 to 15:00 on multiple days of week, i.e. on Mon,Tue,Wed?

The task I described can be defined with the GUI of Task Scheduler by using the 'Advanced' button in the 'Schedule' tab in the task Properties window. Is it possible to define the same task with one schtasks command? If yes, how would the command look like? If not, what would be the workaround.

Here is an example picture:

enter image description here

All the fields in the 'Advanced' window are similar to the Minute schedule type. Yet from what I've tested, it appears that I can't define two schedule types in one command (i.e. Minute + Weekly)

2 Answers 2

1

I believe this is done through using commas to separate the /d command:

schtasks /sc Weekly /tn Backups /d mon,wed,fri /tr [command]

Similar to that.

As for the "repeat every X minutes between Y and Z" portion, I'm afraid that can't be done from the schtasks in Windows XP. In Vista and higher they added this functionality. The above screen would be written as:

schtasks /Create /tn Runthings /tr C:\tasks\runthings.cmd /sc Weekly /d mon,tue,weds /st 08:00 /et 15:00 /ri 10

2
  • sysadmin1138: thanks for the response. I have already known about the /d mon,wed,fri syntax and the command you've provided is a valid part of the solution. I've asked because I can't figure out the second part (8:00 - 15:00 every 10 mins).
    – colemik
    Mar 4, 2012 at 16:17
  • ..., so both parts would work together in one command.
    – colemik
    Mar 4, 2012 at 16:22
2

When options get a bit complicated, an alternative may be to manually create the task using the GUI with the configuration that you need, export it to an XML file, then use the command: SCHTASKS /CREATE /XML <fileName> to create a task on a target computer.

/XML  xmlfile      Creates a task from the task XML specified in a file.
                   Can be combined with /RU and /RP switches, or with /RP
                   alone, when task XML already contains the principal.  

Note that creating tasks from XML files are useful for other purposes, such as if you wanted to adjust the base priority of a task process.

1
  • Unfortunately /xml switch is not supported on Windows XP. Thanks for the response though.
    – colemik
    Mar 5, 2012 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.