Moving Multiple Scheduled Tasks into a Folder on Windows Server 2008

Let’s say you have a whole lot of scheduled tasks you want moved into a subfolder in the Task Scheduler.  Since you can’t just drag and drop the tasks, and must export the jobs into XML files to be imported, we will use similar commands as yesterday’s post.

For this, you will need an empty folder.  I use C:temp for this example.  If your folder does not already exist, create one.  Also, you will need a folder in the Task Scheduler GUI to exist.  Create it using the Task Scheduler GUI.

Export all jobs you want to move into XML files:

  1. Open the Command Prompt, and change to the C:WindowsTasks folder.
  2. Type the following command and press Enter: FOR /R . %F in (*.job) do schtasks /Query /TN “%~nF” /XML > “C:temp%~nF.xml”

This will create all XML files in the C:temp folder.  You can then delete from that folder any XMLs for jobs that you don’t want moved.

Next, delete the jobs in the original folder either using the command line or through the GUI.

Lastly, enter the following command and press Enter:

FOR /R c:temp %F in (*.xml) do schtasks /Create /S <<server name>> /RU <<username>> /RP <<password>> /XML “c:temp%~nF.xml” /TN “<<Task Scheduler folder name>>%~nF”

This will recreate the job files and put the tasks into the folder (in the GUI) of your choosing.

 

Importing Multiple Scheduled Tasks from Windows XP/Server 2003 to Windows 7/Server 2008

On Windows XP and Windows Server 2003, Scheduled Tasks are stored as binary files with the “.job” extension. They are also stored in this manner on Windows Server 2008. Also, the jobs are stored in the same location in both operating systems, namely, “C:WindowsTasks”. So if you want to copy jobs from one to the other, you should just be able to copy the files, right? No, that would be too easy. For whatever reason, Microsoft chose to make it much more difficult to migrate jobs than this.

To successfully import jobs, several steps are required.

First of all, copy all “.job” files on the XP/2003 box into a folder of your choosing on the 2008 box. I’ll create “C:temptasks” for this example.
Next, copy two files – schtasks.exe and schedsvc.dll – from C:WindowsSystem32 on the source box into the C:temptasks folder on the destination box.
Thirdly, copy (don’t move) the job files from the C:temptasks folder into the C:WindowsTasks folder on the destination box.

Now for the fun part. To import a job, the following command must be issued from the Command Prompt:
schtasks /change /TN <<Scheduled Job Name>> /RU <<Username>> /RP <<Password>>

This command will only import one job – the one with whatever name you put in the command.  If you have many jobs to import, this will not be practical.  You’ll need a script to do this, but fortunately the script is simple.

By using a for loop and a basic regular expression, this can be done at the command line:

c:temptasks>FOR /R . %F in (*.*) do schtasks /change /TN “%~nF” /RU <<Username>> /RP <<Password>>

This will import all of your job files into the Task Scheduler. The tasks may be in an enabled state, so be sure to check this if you don’t want them to run yet.

 

Upgrading a Domain Controller from Windows Server 2008 to 2012

When upgrading an Active Directory Domain Controller from Windows Server 2008 (or 2008 R2) to Windows Server 2012, the AD Forest must be upgraded first.  This has to be manually done, as it is not part of the setup process.

To upgrade the AD Forest, right-click on the Command Prompt icon and select “Run as Administrator”.  Insert the Windows Server 2012 DVD (or mount the ISO using a virtual drive) and switch to that drive inside Command Prompt: “cd [Drive letter]: <ENTER>“.

At the command prompt, type “[Drive letter]:supportadprep /forestprep <ENTER>“.  You will be given a warning about how this is not a reversible operation.  Type “C” and hit <ENTER> to continue.  Once this is done, type “[Drive letter]:supportadprep /domainprep <ENTER>“.

After this step is complete, you may proceed with the upgrade to Windows Server 2012.