First published on TECHNET on May 13, 2010
<br/>
Hello again AskPerf! Blake here to show you a not-so-utilized command line tool called Schtasks. The Schtasks command enables an administrator to create, delete, query, change, run, and end Scheduled Tasks on your local or remote system. For those command line junkies who need an easy way to manage their Scheduled Tasks, this is the tool for you. Let’s check out its options and some examples.
When you type “Schtasks /?” from a command prompt, the following appears:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\>schtasks /?
SCHTASKS /parameter [arguments]
Description:
Enables an administrator to create, delete, query, change, run and end
scheduled tasks on a local or remote system.
Parameter List:
/Create Creates a new scheduled task.
/Delete Deletes the scheduled task(s).
/Query Displays all scheduled tasks.
/Change Changes the properties of scheduled task.
/Run Runs the scheduled task on demand.
/End Stops the currently running scheduled task.
/ShowSid Shows the security identifier corresponding to a scheduled task name.
/? Displays this help message.
Examples:
SCHTASKS
SCHTASKS /?
SCHTASKS /Run /?
SCHTASKS /End /?
SCHTASKS /Create /?
SCHTASKS /Delete /?
SCHTASKS /Query /?
SCHTASKS /Change /?
SCHTASKS /ShowSid /?
SCHTASKS /?
Here are some quick examples:
Query a remote system to display its scheduled tasks:
.
C:\>schtasks /Query /S <MachineName>
Folder: /
TaskName Next Run Time Status
=============================== ====================== ===============
Chkdsk 4/6/2010 9:35:00 AM Ready
Disk Cleanup 4/5/2010 9:34:00 AM Unknown
Disk Defragment 4/1/2010 2:00:00 AM Ready
.
Create a scheduled task locally that runs Notepad daily at 10:00AM:
.
C:\>Schtasks /Create /TN Notepad /TR notepad.exe /sc DAILY /ST 10:00 /RU administrator /RP password
SUCCESS: The scheduled task "Notepad" has successfully been created.
.
NOTE: When you use the /U & /P switches from a Vista+ machine to an 2000/XP/2003 machine, you will receive the following error: “ERROR: The request is not supported.”. The feature to run Schtasks.exe under a specific username and password (/U /P) is not supported on legacy machines.
To start the above task then confirm that it is running, type this:
.
C:\>schtasks /Run /TN Notepad
SUCCESS: Attempted to run the scheduled task "Notepad".
C:\>schtasks /Query
Folder: \
TaskName Next Run Time Status
============================== ====================== ===============
Notepad 3/31/2010 10:00:00 AM Running
.
Finally, to delete this scheduled task even though it is running, type this:
.
C:\>schtasks /Delete /TN Notepad /F
SUCCESS: The scheduled task "Notepad" was successfully deleted.
.
As you can see, this tool can be extremely useful at manipulating Scheduled Tasks from the command line, especially if you are trying to access remote machines over slow WAN links. We recommend that you play around with the many options Schtasks provides, and find the ones that work best for you. The links below have more information and examples. Until next time…
Additional Resources:
· How to use Schtasks.exe to Schedule Tasks in Windows Server 2003
-Blake Morrison
Share this post : |
|
|
|
|
|
|
|
|
<br/>
Published Mar 16, 2019
Version 1.0CraigMarcho
Microsoft
Joined March 15, 2019
Ask The Performance Team
Follow this blog board to get notified when there's new activity