Create a Scheduled Task Using Command Prompt

dilipsjain used Ask the Experts™
Dear All,

Using schtasks command i have created a windows scheduled task and it is working fine for the single parameter.
Now i need to create a task with multiple arguments.
For example: My task should run monthly, Sunday of First and Second week.
I was trying something like this but it is giving error.
schtasks /create /tn "mytask" /tr Myapp.exe /sc monthly /mo FIRST,SECOND /d sun /m jan /st 15:00:00 /sd 25-07-2016 /ed 01-04-2035

Can anybody help on this issue.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT / Software Engineering Consultant
Top Expert 2016
I don't see a way to do that via the command line parms, tried several different approaches, although maybe there is an undocumented trick.

Another approach could be to build an XML file that meets your needs and then import that using the /XML option.  I would manually build the task via the GUI Task Scheduler, then export it to an XML so you can see the format, and then use that to import to create the task elsewhere.

Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
I agree, schtasks can only cope with a single schedule type. PowerShell should be able to create several triggers, though. But probably the XML approach is better, as a PS script can get complex. If you do not need much of dynamic changes to the task, I would use XML.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial