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'.
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.
When you specify the task name using
schtasks.exe
you can add any folders you want to use to organize them with.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.
This was my way of doing that, using the command SCHTASKS.exe:
You can get the command help excuting in the command line (cmd or PowerShell):
SCHTASKS /?
, for help on specific subcomand:SCHTASKS /Query /?
, orSCHTASKS /Create /?
, etcList 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.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"
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.