Using the Task Scheduler from the Command Line

by Barry Dysert
(last updated May 12, 2014)

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.

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

Restoring from a Backup

Being able to restore from a backup is just as important as making the backup in the first place. This tip tells you how to ...

Discover More

Understanding and Changing AutoPlay Settings

You can configure Windows to perform some tasks automatically. This includes telling it what to do whenever Windows detects ...

Discover More

Changing Your Internet Home Page

Regardless of the browser you use, there's a way to change its settings so that you can specify where it goes when you click ...

Discover More
More WindowsTips

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 up ...

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

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
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. 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 three more than 8?

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.