The Schtasks.exe utility is used to manage Windows Task Scheduler jobs from the command line. You can use Schtasks.exe to view, run, create, delete or stop the Windows schedule tasks on a local or remote computer. With Schtasks.exe, you can perform all the same actions with the tasks that are performed from the mmc graphical interface of the Task Scheduler console (taskschd.msc).
The Schtasks.exe command has a rather complicated and confusing syntax. To get acquainted with the command, open a command prompt as administrator and run the following command:
As you can see, the utility contains a set of subcommands. Each subcommand has its own syntax.
- Schtasks /Create — Create a new scheduled task;
- Schtasks /Delete — Delete the scheduled task;
- Schtasks /Query — Display scheduled tasks list.
- Schtasks /Change — Changes the scheduled task settings.
- Schtasks /Run — Run the specific task;
- Schtasks /End — Stop the running task;
- Schtasks /ShowSid — Show the task’s security identifier by its name.
For example, to display all available parameters to create a new scheduled task, run the command:
Schtasks /Create /?
If you run the Schtasks command without parameters, it will display all of the scheduler tasks on the local computer (the list contains FolderName, TaskName, Next Run Time and Status).
TaskName Next Run Time Status
automountvhdx N/A Ready
GoogleUpdateTaskMachineCore 4/20/2019 11:09:53 AM Running
GoogleUpdateTaskMachineUA 4/19/2019 2:09:53 PM Ready
To create a new task named RunPing, which executes a certain command every hour, run the command:
SCHTASKS /Create /SC HOURLY /TN RunPing /TR “ping –n 50 192.168.1.1”
SUCCESS: The scheduled task “RunPing” has successfully been created.
Open the Task Scheduler (taskschd.msc) mmc GUI and verify that the new task appears in the Task Scheduler Library list.
To start this task immediately, type the command:
SCHTASKS /Run /I /TN RunPing
SUCCESS: Attempted to run the scheduled task “RunPing”.
As you can see, the command that you specified in the /TR parameter of a new task was launched.
Check the status of this task:
SCHTASKS /query /tn RunPing
As you can see, the task is running:
TaskName Next Run Time Status
======================================== ====================== ===============
RunPing 4/19/2019 3:19:00 PM Running
To force this task to stop, run:
SCHTASKS /end /TN RunPing
SUCCESS: The scheduled task “RunPing” has been terminated successfully.
You can change the scheduled task settings. For example, you want to change the command to the clean DNS cache command:
SCHTASKS /Change /TR “ipconfig /flushdns” /TN RunPing
SUCCESS: The parameters of scheduled task “RunPing” have been changed.
Similarly, you can prohibit the execution of a scheduled task on a configured schedule:
SCHTASKS /Change /TN RunPing /DISABLE
Or activate the task to run by schedule:
SCHTASKS /Change /TN RunPing /ENABLE
To get detailed information about a specific task, run the command:
schtasks /query /tn runping /v /fo list
Next Run Time: 4/19/2019 3:19:00 PM
Logon Mode: Interactive only
Last Run Time: 4/19/2019 2:20:14 PM
Last Result: 267014
Task To Run: ipconfig /flushdns
Start In: N/A
Scheduled Task State: Enabled
Idle Time: Disabled
Power Management: Stop On Battery Mode, No Start On Batteries
Run As User: root
Delete Task If Not Rescheduled: Disabled
Stop Task If Runs X Hours and X Mins: 72:00:00
Schedule: Scheduling data is not available in this format.
Schedule Type: One Time Only, Hourly
Start Time: 2:19:00 PM
Start Date: 4/19/2019
End Date: N/A
Repeat: Every: 1 Hour(s), 0 Minute(s)
Repeat: Until: Time: None
Repeat: Until: Duration: Disabled
Repeat: Stop If Still Running: Disabled
To delete the scheduled task, run:
schtasks /delete /tn runping
You can use schtasks to manage tasks on a remote computer, just enter the name of the remote computer using the /S parameter.
For example, delete the CheckService task on the remote computer ServerOH1:
schtasks /delete /TN "CheckService" /S ServerOH1
- How to Setup Gmail in Outlook? - October 14, 2021
- How to Clear Browsing History in Safari on iPhone/iPad? - October 11, 2021
- Allow Non-administrators to Install Printer Drivers via GPO - October 1, 2021