When I decommissioned my Windows Home Server recently, I decided to replace it with Windows 7. However, I had over 20 scheduled tasks running on the WHS box to do things like back up my websites and backup files on the server and such.
I wanted to recreate these scheduled tasks on the new Windows 7 install, but discovered that Microsoft had changed the format for scheduled tasks in Win7 and provided no mechanism for importing the old .job files from Windows XP / Windows 2003. Windows 7 now uses XML files for import and exporting task definitions – but no conversion tool from the old .job format.
I really didn’t want to be spending the time manually recreating all of these tasks, but a bit of Google research found a possible solution involving remote invocation of the schtasks command line tool. Here’s what I did.
The first issue was that I had already decommissioned the WHS install, although I did save the C & D partitions on the system drive so I could have theoretically booted it up again. However, I had already changed some of the machine’s hardware (new MoBo, new SATA controller, etc), so that was always going to be a last resort and fraught with potential boot-up issues.
Fortunately I still had an old laptop running Windows XP, so I was able to copy the .job files I had backed up from the WHS box over to the XP machine and have them recognised by Task Scheduler there.
Next, I ran the following command on my Windows 7 laptop from an “elevated” command prompt (Start -> All Programs -> Accessories -> right mouse click on “Command Prompt” and select “Run as administrator”):
schtasks /Query /S remote_computer_name /U remote_username /P remote_password /XML > output_file.xml
… where the “remote_computer_name” was the name of my Windows XP machine, and “remote_username” and “remote_password” were for a valid administration user on that machine.
This command tells the remote machine to dump a list of all parameters for all scheduled tasks and send it to my console and the /XML flag tells the Windows 7 box to convert that information to the new XML format, and then I piped the output to a new file, “output_file.xml”.
The output was a concatenated list of all XML task data (which itself is not a valid file to import into Windows 7 task scheduler), so I used a text editor to copy and paste the individual tasks that I wanted to recreate and then used the “import” feature in Windows 7 task scheduler to import the new task. I believe there is a flag you can set to have the combined output XML for all the tasks be valid to import directly, but I didn’t try that, preferring to manually select which of the tasks to import and doing them one at a time so I could then check the settings each time.
There are a plethora of new features and settings in Windows 7 task scheduler, so it does pay to verify and tweak any settings after importing them. I really am quite impressed with the new functionality in Windows 7 task scheduler!