How to import a scheduled task from an XML file?

I have created a scheduled task in Windows 7, which will run a batch file once a day. The task is running perfectly well on my computer.

I have also exported the task to an XML file and want to create the same task on another computer. How can I import the XML file in Task Scheduler on the second computer?

Specifically – I don't want to write any code on new computer, I just want to copy the XML file to it and it should create a task and start running it.


Solution 1:

When you open Task Scheduler on the new computer, click on "Import Task..." in the Actions list on the right-hand side of the window:

enter image description here

Select the XML file and click "Open", then review the parameters in the "Create Task" window that opens, and click "OK".


If you need to do this programmatically, you can use schtasks.exe. The following code should import the XML file and create a new task automatically:

schtasks.exe /Create /XML task.xml /tn taskname

Just replace "task.xml" with the path to your XML file, after it's been copied to the correct location, and replace "taskname" with whatever name you want it to appear as in Task Scheduler.