How to Import / Export (Backup / Restore) Tasks Using Task Scheduler in Windows?

Task Scheduler is a very useful components in Windows. It can be used to create a reminder for an important meeting or to schedule any particular task which you perform regularly.

I always use Task Scheduler to schedule my important tasks. At the moment I have 24 scheduled tasks in Task Scheduler.

Creating a task is very easy in Task Scheduler. Simply click on Create Task link, follow instructions and enter required details like Task name, scheduled date/time, message, etc and your new task is ready to launch on the scheduled date/time.

Advertisement

Once you create a task, you should take a backup of the task so that you can restore it whenever required. Suppose you get a new computer or format your existing computer, you’ll not need to create the task again. Just restore the task and you are done.

In this tutorial, we’ll tell you how to take a backup of the task and how to restore the task using Task Scheduler.

How to Take Backup (Export) Tasks in Task Scheduler:

1. Go to Start -> All Programs -> Accessories -> System Tools and click on “Task Scheduler“.

You can also open it directly using taskschd.msc command in RUN or Start menu Search box.

2. Once Task Scheduler is launched, select any desired task and click on “Export” link given in Actions pane at right-side of the window.

Or you can right-click on the task and select “Export” option.

Export_Backup_Task_Scheduler.png

Advertisement

3. Browse to the location where you want to save the task backup and click on Save button.

4. That’s it. It’ll save a XML file containing all the details about your task.

PS: Windows XP users will need to copy the task and paste it at your desired location where you want to save the backup.

How to Restore (Import) Tasks in Task Scheduler:

1. Again open Task Scheduler and click on “Import Task” link given in Actions pane at right-side of the window.

Import_Backup_Task_Scheduler.png

2. Now browse to the location where you have the backup of the task and select the XML file. At last click on Open button.

3. Task Scheduler will show a dialog box showing details of your task, click on OK button.

4. That’s it. It’ll restore your task.

PS: Windows XP users will only need to copy the backup task into Task Scheduler window.

Published in: Troubleshooting Guides, Windows 7, Windows Vista, Windows XP

About the author: Vishal Gupta (also known as VG) has been awarded with Microsoft MVP (Most Valuable Professional) award. He holds Masters degree in Computer Applications (MCA). He has written several tech articles for popular newspapers and magazines and has also appeared in tech shows on various TV channels.

Comments

NOTE: Older comments have been removed to reduce database overhead.

  1. Here’s how to export and import all tasks at command line on Windows 7 or Windows 2008 Server

    Before you begin you should know these:
    – The job files are located in C:\Windows\System32\Tasks and its subfolders.
    – The Task job folder in W2003Srv is C:\Windows\Tasks.
    – The W2003Srv tasks can be imported to W2008Srv: Run the schtasks.exe -export commands at W2008Srv using /s [W2003Srv_computername] -switch.
    – The Sheduled tasks GUI is found at Control Panel\All Control Panel Items\Administrative Tools\Task Scheduler.
    – You can also delete task with:
    a) At command line with SCHTASKS, e.g: schtasks.exe /delete /TN “\Folder1\Task1”
    b) Deleting job file, e.g: del C:\Windows\System32\Tasks\Folder1\Task1
    – W2008Srv has some 80 preconfigured scheduled tasks.
    – Do not use SCHTASKS /Delete /TN * -command in W2008Srv, it will delete also the preconfigured tasks.

    1) Create a task list

    schtasks.exe /query /fo CSV|Findstr /v “^\”TaskName\”.*$”>TaskList.txt

    Explanation:
    schtasks.exe = Command for listing, creating and editing Scheduled Tasks.
    /query = List tasks
    /fo = Format Output.
    CSV = Output format is Comma Separated Values.
    | = Pipe = Pass the results from the left side of the pipe character to the right side.
    Findstr = Command to filter the headers from the output.
    /v = Show all but matching lines.
    “^\”TaskName\”.*$” = Regular expressions saying: Match lines beginning with: “Taskname”
    >TaskList.txt = Put the result in the TaskList.txt file.

    The TaskList.txt now contains list of all the tasks, one task per line. After installation Windows 7 has about 70 preconfigured tasks.
    The TaskList.txt looks like this:
    ——————————————————————————–
    ….
    “\SomeTaskAtRoot”,”N/A”,”Ready”
    “\Microsoft\Windows\Autochk\Proxy”,”N/A”,”Ready”
    “\Microsoft\Windows\Defrag\ScheduledDefrag”,”19.1.2011 2:12:10″,”Ready”
    “\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask”,”19.1.2011 15:04:30″,”Ready”
    “\OfficeSoftwareProtectionPlatform\SvcRestartTask”,”Disabled”,””
    ….
    ——————————————————————————–

    You can edit TaskList.txt for example to remove the task lines you don’t want to copy to the target computer.

    2) Export = Create a XML file for each task.

    FOR /F “tokens=1,2* delims=,” %a IN (TaskList.txt) DO schtasks.exe /query /TN “%~a” /XML > “%~nxa.xml”

    Explanation:
    FOR = Use For command to handle the TaskList.txt.
    /F = This For command uses switches.
    For command switches: two or more parameters (tokens=1,2*) delimited with commas (delims=,).
    %a = The first parameter name is ‘a’, second is ‘b’ and so on.
    “%~a” = The task name is the first parameter of each line (e.g “\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask”).
    /XML = Output format id XML.
    > “%~nxa.xml” = Put the result in this file (e.g “SvcRestartTask.xml”)

    Warning!
    If many tasks has the same name (“SvcRestartTask.xml”, see example above), only the latter will be exported.

    3) Import.
    Copy the TaskList.txt and the XML files you exported to target computer and run this at target computer’s command line to create the the tasks:

    FOR /F “tokens=*” %a in (TaskList.txt) do @echo schtasks.exe /create /TN “%~a” /XML “%~na.xml” > TaskList.log 2>&1

    The TaskList.log has log of each task create event telling you whether the create was OK or not.

Leave a Comment

Your email address will not be published. Required fields are marked *

NOTE: Your comment may not appear immediately. It'll become visible once we approve it.