Migrating Scheduled Task Jobs

Migrating Scheduled Task Jobs

Finally retiring that old Windows Server 2003 machine? Need to migrate your scheduled tasks? Here is an easy solution.

One of our clients is finally migrating from Windows Server 2003 to Windows Server 2012 (don't judge) and I ran into an interesting problem. They have a bunch of jobs set up in the Task Scheduler that need to be migrated over, but the old machine uses a deprecated binary .job file format to store the job data, while the newer machine uses an xml-based file format.

Of course, there is a built-in solution for this problem: the schtasks program now has an /XML switch to export an xml file. However, that version of schtasks only works on the newer OSes, so you cant easily convert the scripts on your old machine.

Surely Google can help, right? It didnt take long to find several solutions like this that let you specify the remote host name of the older OS. In that case, you can use the newer schtasks (with xml export) but point it at the older machine and everything is easy-peasy.

But that only works if the two machines are on the same domain and can see each other. In my case, we were moving from one virtual hosting company to another, so the two machines could not interact in this way.

Back to Google and I find a long-winded but working solution that requires you to copy the old version of schtasks to the new machine, pipe some directory output to text file, manually create an Excel spreadsheet that gets saved as a .bat file and eventually execute schtasks on a copy of the old jobs. Whew - there had to be a better way! So I whipped one up.

class Program
        static void Main(string[] args)
            var username = Console.ReadLine();
            var password = Console.ReadLine();
            var files = Directory.GetFiles(@"c:\windows\tasks", "*.job");
            if (files == null || files.Count() == 0)
                Console.WriteLine("No .job files found to process");
                foreach (var file in files)
                    var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
                    var arguments = String.Format("/change /TN {0} /RU {1} /RP {2}", fileNameWithoutExtension, username, password);
                    var psi = new ProcessStartInfo(@"schtasksXP", arguments);
                    psi.UseShellExecute = false;
                    Console.WriteLine(psi.FileName + " " + psi.Arguments);
                    var p = Process.Start(psi);
            Console.WriteLine("Press any key to continue...");

To use it:

  • Copy your old .job files to C:\Windows\Tasks on the new machine
  • Download the .zip file and unzip the contents to a folder
  • Run TaskScheduleJobConverter.exe which will prompt you for a username & password to be used to execute the imported jobs

When the script completes, all of the old jobs will have been converted and imported into the new machine's Task Scheduler.

Download the program