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:
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.
It's easy to have a program run when Windows starts. In fact, by using the Task Scheduler, you can have all sorts of ...
Discover MoreIf you have certain programs that you want to have run automatically, you can use Windows Task Scheduler to quickly set ...
Discover MoreIf 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 MoreThere are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Copyright © 2024 Sharon Parq Associates, Inc.
Comments