How to export Task Scheduler jobs in Windows?
Windows has provided a graphical interface to export Task scheduler job.
But the graphical interface allows exporting one selected job only.
It does not allow exporting more than one.
Which basically means importing of task scheduler jobs, can be done one by one only.
See image below on how to export a task in Windows.
Where to find Task Scheduler jobs?
Tasks scheduler jobs can be found on c:\windows\system32\tasks folder.
To open a particular tasks just type notepad plus the filename. The command prompt should be open at an elevated mode.
It will open the job and in XML format. See image below:
If you have quite a few tasks running on a server or different servers which runs different tasks job.
It's gonna be fun to do it manually and I guess Microsoft expect Windows System Administrator to have some fun once in a while.
It has to be done manually also, because the command line schtasks.exe does not even support exporting of tasks job.
So scripting is out of the option to automate tasks job exporting.
Here's the command line output of schtasks.exe option and parameters:
C:\Windows\System32\Tasks>schtasks /?
SCHTASKS /parameter [arguments]
Description:
Enables an administrator to create, delete, query, change, run and
end scheduled tasks on a local or remote system.
Parameter List:
/Create Creates a new scheduled task.
/Delete Deletes the scheduled task(s).
/Query Displays all scheduled tasks.
/Change Changes the properties of scheduled task.
/Run Runs the scheduled task immediately.
/End Stops the currently running scheduled task.
/? Displays this help message.
Examples:
SCHTASKS
SCHTASKS /?
SCHTASKS /Run /?
SCHTASKS /End /?
SCHTASKS /Create /?
SCHTASKS /Delete /?
SCHTASKS /Query /?
SCHTASKS /Change /?
Export option cannot be found from that simple help option.
Running the command below will provide more options and parameters.
C:\Windows\System32\Tasks>schtasks /query /?
SCHTASKS /Query [/S system [/U username [/P [password]]]]
[/FO format | /XML [xml_type]] [/NH] [/V] [/TN taskname] [/?]
Description:
Enables an administrator to display the scheduled tasks on the
local or remote system.
Parameter List:
/S system Specifies the remote system to connect to.
/U username Specifies the user context under
which schtasks.exe should execute.
/P [password] Specifies the password for the given
user context. Prompts for input if omitted.
/FO format Specifies the format for the output.
Valid values: TABLE, LIST, CSV.
/NH Specifies that the column header should not
be displayed in the output. This is
valid only for TABLE format.
/V Displays verbose task output.
/TN taskname Specifies the task name for which to
retrieve the information, else all of them.
/XML [xml_type] Displays task definitions in XML format.
If xml_type is ONE then the output will be one valid XM
L file.
If xml_type is not present then the output will be
the concatenation of all XML task definitions.
/? Displays this help message.
Examples:
SCHTASKS /Query
SCHTASKS /Query /?
SCHTASKS /Query /S system /U user /P password
SCHTASKS /Query /FO LIST /V /S system /U user /P password
SCHTASKS /Query /FO TABLE /NH /V
From this Technet link, it shows how to export a task via command line using this method below:
schtasks /Query [/S [/U username [/P password ]]]] /XML /TN
But exporting has to be copied and save manually.
From the Technet link above states that:
The XML for the task is shown in the command prompt.
Copy the XML for the task and paste it into a blank XML file.
When the XML file is saved, the file will contain the task definition and can be imported.
You run the command, copy the output and save it as XML file.
Wow, an exceptional way of exporting a file.
I think to save time, anyway exporting needs to be done one by one also.
For exporting tasks, just copy the whole c:\windows\system32\tasks folder. Copy whatever is on the tasks folder.
It will save time rather than exporting one by one, and on the machine or server in which the tasks will be imported.
Open task scheduler then import one by one the tasks, and of course check whether some parameters, user name and password need to be changed and other details if there are some changes.
I guess in this way, it will be better rather than starting from scratch and miss some minor details.
Is exporting of Task Scheduler jobs important?
Well, if you just inherited a server from another administrator.
Or even you have a server that you build from scratch and after 8 or 10 years on the road.
And you are still on the same comfort zone.
Most probably you might have forgotten what is running on the task scheduler.
Unless you have a powerful memory that can always remember along the weary road of life.
So when server migration is needed, the server has crash or the server needs to be changed.
Task scheduler is one of the option that is easily forgotten or not even considered.
So what if the Task Scheduler was running a very simple backup or copy job?
And along the road, data was lost or corrupted and some tasks should be running on the task scheduler.
But it was just missed out because task scheduler was not just on the plan, the result could be a disaster.
Server migration and operation would perfectly run, but Task Scheduler jobs are equally important as well.
Conclusion is, to export task scheduler and save some time.
- Copy the c:\windows\system32\tasks\ ..copy whatever is on this folder
- To export on another server, used the GUI method and point to the folder where the files were saved
But it has to be done one by one, so I guess make sure some glass of coffee is on the side.
This folder location "c:\windows\system32\tasks\" is the folder which the configured jobs are saved. Windows 2008, Windows 2012 and Windows 7 uses this folder location to saved tasks configured for windows scheduler.
Cheers..hope it helps..Enjoy..
Comments
Post a Comment