13

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.

3
  • 2
    Based on the comments to the answer below, it appears that the question is more about how to schedule tasks via programming rather than through the end user interfaces. StackOverflow would be a better place to ask that, since that is a Q&A site for developers.
    – Thomas
    Jul 16, 2015 at 21:14
  • I think this site is quite fine for this question. We are not programming here, but instead, we are using the command line to import the task as configured in XML format. Creating XML should not be considered to be programming, since XML is just a way to represent hierarchical data, and we can consider that to be configuration instead of code. Feb 14, 2021 at 16:17
  • 1
    I also wanted to point out that, even though this thread is pretty old, it is still relevant and helpful as of February 2021 with Windows 10, since the task scheduler still looks the same and works in the same ways, at least to the extent of what this thread is trying to accomplish. I am not a windows expert, nor am I an expert with the task scheduler, so your mileage may vary, as they say. Feb 14, 2021 at 16:19

1 Answer 1

20

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.

8
  • I want to eliminate those steps. Let me explain you my query in detail: I am creating windows application using SQL Server Express. I had created backup plan in t-sql, used batch file and task scheduler to do backup once in a day. Our users download application online so there is no other way for us to setup task scheduler manually. I am not sure how to achieve this task. I am reading windows services, C#.NET and so on. Can you guide me in proper context? Oct 9, 2012 at 18:53
  • 1
    Does your application have some sort of installer? If so, you can call schtasks.exe /Create /XML task.xml to create the task automatically (see this MSDN article on schtasks.exe for more information). But I don't think there's a way to have the task created simply by copying an XML file somewhere and nothing else.
    – Indrek
    Oct 9, 2012 at 18:58
  • i am using install shield for installation of my application Oct 9, 2012 at 19:05
  • 2
    Thank you for this. I used this to set up a scheduled task that will update Linux in WSL2 every time I log in. Even though this thread is super old, it still applies on Win 10 in February 2021! If the OP and person who provided the accepted answer sees this, I hope it gives them a feeling of satisfaction that their efforts continue to be helpful. That is one of the reasons why this community is so great. Feb 14, 2021 at 16:14
  • 2
    @SteveStorck Can't speak for the OP, but it's always nice to see old posts of mine still being helpful to someone. Thanks for taking the time to comment!
    – Indrek
    Feb 14, 2021 at 18:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .