Skip to main content

Export Task Scheduler Jobs in Windows



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

Popular posts from this blog

WMIC get computer name

WMIC get computer model, manufacturer, computer name and  username. WMIC is a command-line tool and that can generate information about computer model, its manufacturer, its username and other informations depending on the parameters provided. Why would you need a command line tool if there’s a GUI to check? If you have 20 or 100 computers, or even more. It’s quite a big task just checking the GUI to check the computer model and username. If you have remote computers, you need to delegate someone in the remote office or location to check. Or you can just write a batch file or script to automate the task. Here’s the code below on how get computer model, manufacturer and the username. Open an elevated command prompt and type:     wmic computersystem get "Model","Manufacturer", "Name", "UserName" Just copy and paste the code above, the word “computersystem” does not need to be change to a computer name. A...

Notepad++ convert multiple lines to a single line and vice versa

Notepad++ is an awesome text editing tool, it can accept regex to process the text data. If the data is in a “.csv” format or comma separated values which is basically just a text file that can either be opened using a text editor, excel or even word. Notepad++ can process the contents of the file using regex. Example if the data has multiple rows or lines, and what is needed is to convert the whole lines of data into a single line. Notepad++ can easily do it using regex. However, if the data is on a single line and it needs to be converted into multiple lines or rows then regex can also be used for this case. Here’s an example on how to convert multiple rows or lines into a single line. Example data: Multiple rows, just a sample data. Press Ctrl+H, and  on "Find what" type: [\r\n]+ and on "Replace with" type with: , (white space) --white space is needed if need to have a space in between the data. See image below, "Regular Expression" must be se...

Print error 016-799 - Fuji Film Xerox

016-799 Fuji Xerox or Fuji Film print error code. That shows a description error as “Print instruction Fail detected in decomposer.” The error code and error description are alien languages for users and even system administrators who are not familiar with Fuji Xerox error code. The error code is quite simple and easy to fix, if the job print goes to the printer but print out doesn’t come out. So, basically the print job was received by the printer, but the printer just doesn’t know what type of paper or what size to use or which tray to utilize for the print out. In some instances, this is just a paper mismatch but the error description; if using Windows 10 to print does not exactly points to what is the issue. First thing to check, is the paper size selected by the user to print. Example, if the printer configuration is A3 and A4 sizes only. But then the person printing the file accidentally chooses “A4 Cover” then this error 016-799 will occur. ...