Using Schtasks.exe

Using Schtasks.exe to Manage Schedule Tasks in Windows


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:

schtasks.exe /?

schtasks exe

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 /?

schtasks

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

For example:

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

schtasks command line

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.

windows schtasks

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.

schtasks windows 10

Check the status of this task:

SCHTASKS /query /tn RunPing

As you can see, the task is running:

Folder: \

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

schtasks command

To get detailed information about a specific task, run the command:

schtasks /query /tn runping /v /fo list

schtasks create task

Folder: \

HostName: DESKTOP-JOPF9

TaskName: \runping

Next Run Time: 4/19/2019 3:19:00 PM

Status: Ready

Logon Mode: Interactive only

Last Run Time: 4/19/2019 2:20:14 PM

Last Result: 267014

Author: DESKTOP-JOPF9\root

Task To Run: ipconfig /flushdns

Start In: N/A

Comment: 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

Days: N/A

Months: 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

schtasks delete

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

You may also like:

Deploy LGPO with MDT 2013 Local Group Policy (LGPO) of computer is configured through gpedit.msc snap-in, which does not provide the possibility to export/import settings. That...
Using PsExec to Run Commands Remotely The PsExec is an easy Windows utility to replace the telnet tool. It allows you to run programs and processes on remote systems, using all the feature...
How to Migrate User Profiles with User State Migra... One of the most popular tools to migrate user profiles from one Windows computer to another is the set of CLI utilities – User State Migration Tool (U...
How to Mount Windows Folder into VMware ESXi In this article we will take a look on how to connect a network folder from Windows 2012 R2 Server as a datastore on the VMware ESXi host and use it t...
Store BitLocker Recovery Keys using Active Directo... In a domain network, you can store the BitLocker recovery keys for encrypted drives in the Active Directory Domain Services (AD DS). This is one of th...

Add Your Comment