Creating a scheduled task with multiple actions using command line in Windows server 2008

I had the need to create a scheduled task on a Windows Server 2008 server that executed mutiple actions.   For those who haven’t worked with Windows Server 2008 new task scheduler, there are links listed below to help with that.  My post assumes you know about task scheduler and want to go one step further and automate creating using the command prompt.

To get started, on a single machine.  Create the scheduled task you want to run, this would include all the necessary actions. 

Create multiple actions.

Export the scheduled task

Here is the output from the export step.  Notice at the bottom it has the EXEC command.   

<?xml version=”1.0″ encoding=”UTF-16″?>
<Task version=”1.2″ xmlns=”“>
    <Principal id=”Author”>
  <Actions Context=”Author”>

To automate creation, run from the command prompt.  For my testing, I created the task under one name and when I used the command prompt, I gave the TN (task name) property something else so I could have both jobs on my test box.

C:WindowsSystem32schtasks /create /tn “RunSomeTaskWith2Actions” /RU DomainNameUsername /RP Password1 /xml \FileServerFileShareExportedFile.xml

PS – To create the task on several machines, you could use a powershell script or something to call WMI (win32_process) to create everywhere.  With a little scripting and this, the task could be automated.  I hope this is helpful. 

 Additional resources







Steve Schofield
Microsoft MVP – IIS