Using the Task Scheduler from the Command Line

Written by Barry Dysert (last updated September 4, 2017)

In a different tip (Understanding the Task Scheduler) you learned about the GUI interface for the program. It's often more convenient, though, to manipulate tasks from the command line instead of launching the GUI. This tip covers several command-line uses of the Task Scheduler.

All commands to the Task Scheduler use the SCHTASKS command. You can learn the details about this command by typing SCHTASKS /? at a command prompt. This tip covers these basic commands:

  • Query: See what all scheduled tasks exist.
  • Run: Cause a scheduled task to run.
  • End: Cause a scheduled task to end.
  • Delete: Delete a scheduled task from the Task Scheduler.

It is possible to create a task from the command line, but the syntax is a bit unwieldy. What I do if I think I'll need to create a task from the command line is to first create it using the GUI interface and then export its XML file. This file can then be used when doing a SCHTASKS /Create.

To see what scheduled tasks exist in the Task Scheduler, enter this command:

C:\> SCHTASKS /Query

If you have more than a few scheduled tasks, the output from this command can be somewhat hard to digest. You can modify the format of the output by using the /FO switch. The default output format is "Table", so if you want to have it formatted as "List" you would add an /FO List to the query. Unfortunately, this really isn't much better than the Table format. The last way is to have it formatted as "Csv" and direct the output to a file. You can then open this CSV file in Microsoft Excel to easily view it. Here's the command:

C:\> SCHTASKS /Query /FO Csv > tasks.csv

I typically use the /Query switch just to see if a given task exists in the Task Scheduler. This is accomplished quite easily by piping the output to the FIND command and searching for the given task. So if I want to know if the task "Backups" is in the Task Scheduler I would do it like:

C:\> SCHTASKS /Query | FIND/I "Backups"

You use the /Run switch to cause an existing scheduled task to immediately run. The syntax is rather straightforward. Let's say I want to cause my "Backups" task to run right now. I would type:

C:\> SCHTASKS /Run /Tn Backups

(What follows the /Tn switch is the task name that is to be run.)

You use the /End switch to cause a task to end. The syntax is again straightforward. So if I want to end my "Backups" task I would type:

C:\> SCHTASKS /End /Tn Backups

Finally, you can delete a task from the Task Scheduler altogether by using the /Delete switch. So if I want to delete the task named "Temptask" I would type:

C:\> SCHTASKS /Delete /Tn Temptask

 This tip (9987) applies to Windows 7 and 10.

Author Bio

Barry Dysert

Barry has been a computer professional for over 35 years, working in different positions such as technical team leader, project manager, and software developer. He is currently a software engineer with an emphasis on developing custom applications under Microsoft Windows. When not working with Windows or writing Tips, Barry is an amateur writer. His first non-fiction book is titled "A Chronological Commentary of Revelation." ...

MORE FROM BARRY

Creating a Custom View in the Event Viewer

Creating a custom view in the Event Viewer allows you quick access to those events you're interested in watching over ...

Discover More

Copying Data with Robocopy

Robocopy is a robust file copy utility built into Windows. If you have a lot of file management to do that can't easily ...

Discover More

Using Powercfg to Delete an Existing Power Scheme

You may have created a new power scheme for whatever reason, but when it has outlived its usefulness, you want to delete ...

Discover More
More WindowsTips

Modifying or Deleting a Program's Schedule

Windows makes it easy to define tasks and to run them on a regular schedule. If you later want to modify or delete a ...

Discover More

Understanding the Task Scheduler

If you want to have a program run at a certain time or when a specific system event occurs, you'll want to understand the ...

Discover More

Scheduling a Program to Run on a Schedule

If you have certain programs that you want to have run automatically, you can use Windows Task Scheduler to quickly set ...

Discover More
Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 - 0?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


Newest Tips