Using the Task Scheduler from the Command Line

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 30 years, working in different positions such as technical team leader, project manager, and software developer.  He is currently a senior software engineer with an emphasis on developing custom applications under Microsoft Windows. ...

MORE FROM BARRY

Starting Applications Automatically when Starting Windows

Understanding the Task Scheduler is a great asset when you want your computer to do things automatically. This tip shows you ...

Discover More

Backing Up the Windows Registry

Windows wouldn't function if it weren't for the Registry. It's important, therefore, to back it up—especially before ...

Discover More

Using Sync Center

Sync Center is a centralized place where you can deal with your offline files. You can do a manual sync, set up a sync ...

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 task, ...

Discover More

How to Run a Program when Windows Starts

It's easy to have a program run when Windows starts. In fact, by using the Task Scheduler, you can have all sorts of things ...

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
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

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}] 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 four less than 6?

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


Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.