Well, the time has come for me to learn at last syntax for schtasks what I was reluctant to do. Some time you have to migrate a task or a bunch of them from one computer to another. In my case it was even more “interesting” task: migrate some tasks from Windows Server 2003 box to Windows 2008 R2. If you have only one it is no problem to move it manually, but what if there are many of them? Here it is: the moment of schtasks’ triumph! =)
What it can do for us is to export 2003’s tasks into an XML file. Suppose we have task “Command Prompt” which launches cmd.exe once:
Now let’s use our secret weapon (run it from 2008 box):
In Task.xml we now have the following content:
1: <?xml version="1.0" encoding="utf-16"?>
2: <Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
3: <RegistrationInfo>
4: <Author>trofimov</Author>
5: </RegistrationInfo>
6: <Triggers>
7: <TimeTrigger>
8: <Enabled>true</Enabled>
9: <StartBoundary>2011-04-10T23:43:00</StartBoundary>
10: </TimeTrigger>
11: </Triggers>
12: <Settings>
13: <Enabled>true</Enabled>
14: <DeleteExpiredTaskAfter>PT0S</DeleteExpiredTaskAfter>
15: <ExecutionTimeLimit>PT259200S</ExecutionTimeLimit>
16: <Hidden>false</Hidden>
17: <WakeToRun>false</WakeToRun>
18: <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
19: <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
20: <RunOnlyIfIdle>false</RunOnlyIfIdle>
21: <Priority>5</Priority>
22: <IdleSettings>
23: <Duration>PT600S</Duration>
24: <WaitTimeout>PT3600S</WaitTimeout>
25: <StopOnIdleEnd>false</StopOnIdleEnd>
26: <RestartOnIdle>false</RestartOnIdle>
27: </IdleSettings>
28: </Settings>
29: <Principals>
30: <Principal>
31: <UserId>System</UserId>
32: </Principal>
33: </Principals>
34: <Actions>
35: <Exec>
36: <Command>C:WINDOWSsystem32cmd.exe</Command>
37: <WorkingDirectory>C:WINDOWSsystem32</WorkingDirectory>
38: </Exec>
39: </Actions>
40: </Task>
which we can now import to our W2008R2 box with schtasks or even through GUI:
Of course, doing that with schtasks is more efficient way to import more than one task, but GUI is much more spectacular 😉
Thank you! nice tutorial!
BTW, The “author” field was painted on the image… but i can clearly read “trofimov” on the XML 😛
Jeez… That’s how good people are compromised!!! )
thanks for noting, next time I’ll be more conscious =)
I do not understand this statement:
Now let’s use our secret weapon (run it from 2008 box):
Hello,
that means that we should use the discussed command, but only from windows 2008 or later OS.
Hi,
I tried have exported all the task in 2003 server and while importbg am getting error.
The formant of the tasl is not valid. The following error was reported:
(2,3): Tasks:
Hello, Indrakumar.
where are you importing the list to? What kind of OS?
Hi,
I have windows server 2003 and window 7.
i tried to export all of Scheduled task of server 2003 using Window 7.
but i encoutered error: Access is denied
What kind of account have you used? Is it a local admin on the target 2003 box?
Step by Step easiest solution:
1. Open Task Scheduler(TS) in Windows 2008 or 2012
2.Select top node on the left pane named “Task Scheduler(Local)”
3. Click on “ACTION” Menu on the top , and select “Connect to Another Computer..”, Ken in the IP address or the name of your 2003 server and click OK.
4.Click on the 2nd Node on the left pane named “Task Scheduler Library”, you might get a message box with info “Copyconfig.job” no longer exists…just ignore it and click OK, you should see all your 2003 server scheduled jobs on the right pane.
5.Select the 2003 tasks one at a time , then right click and select export…export it to a known location.
6. Once you are done exporting all the 2003 tasks, close the Task Scheduler and reopen it.
7.Click on the ACTION menu, select Import and import from the exported location One Job at a time , make sure to user account under whom the jobs needs to be run in the new server.
thanks, Shrimant! I haven’t tested it, but I’m sure it works. If you don’t need to do some automation it is a great way to migrate tasks!