7

I have several standalone Win2008 (R1+R2) servers (no domain) and each of them has dozens of scheduled tasks. Each time we set up a new server, all these tasks have to be created on it.

The tasks are not living in the 'root' of the 'Task Scheduler Library' they reside in sub folders, up to two levels deep.

I know I can use schtasks.exe to export tasks to an xml file and then use:

schtasks.exe /CREATE /XML ...' 

to import them on the new server. The problem is that schtasks.exe creates them all in the root, not in the sub folders where they belong. There is also no way in the GUI to move tasks around.

Is there a tool that allows me to manage all my tasks centrally, and allows me to create them in folders on several machines? It would also make it easier to set the 'executing user and password'.

Peter Hahndorf
  • 13,763
  • 3
  • 37
  • 58

3 Answers3

2

So as nobody here had an answer, I sat down and wrote a small program myself.

It imports existing tasks into a database. You can then copy the database to another machine and create all the tasks in the same folder structure on the new machine.

You can also use it, to rename tasks, move them into different folders or delete multiple ones with a single click.

It requires .NET 4 and Vista or newer.

Peter Hahndorf
  • 13,763
  • 3
  • 37
  • 58
2

When you specify the task name using schtasks.exe you can add any folders you want to use to organize them with.

Schtasks.exe /create /xml taskname.xml /TN folder1\taskname

will create folder1 and then create taskname inside it.

It doesn't help you move already created tasks, but it does help you manage new ones.

Felix Frank
  • 3,063
  • 1
  • 15
  • 22
1

This was my way of doing that, using the command SCHTASKS.exe:

  1. You can get the command help excuting in the command line (cmd or PowerShell): SCHTASKS /?, for help on specific subcomand: SCHTASKS /Query /?, or SCHTASKS /Create /?, etc

  2. List your task in the source hosts

SCHTASKS /Query /FO CSV | clip

Here I copy the task in the clipboard, then extract them in a text editor. I used: https://regexr.com/, an online regular expression utility.

  1. With the list of tasks, I built the commands (using a spreadsheet is a good idea, with "concatenate" functions) to extract the definitions in xml files:

Note the /TN (Task Name) has the folder name, and the file name doesn't.

SCHTASKS /Query /XML /TN "\Replication\Delete Old Replication Logs" > "Delete Old Replication Logs.xml"

  1. Then I copied the xml files to the target host, generated the commands and execute them in a command line console opened with administrator privileges located where the xml files are.

SCHTASKS /Create /RU yourdomain\youruser /RP yourpassword /TN "\Replication\Delete Old Replication Logs" /XML "Delete Old Replication Logs.xml"

Thats all, this method worked for me, maybe for other people would too.