Schtasks
Encyclopedia
schtasks is a command
Command (computing)
In computing, a command is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. Most commonly a command is a directive to some kind of command line interface, such as a shell....

 which schedules
Job scheduler
A job scheduler is a software application that is in charge of unattended background executions, commonly known for historical reasons as batch processing....

 other commands to be run at a certain time. It may run a command once, or repeatedly based upon the day of the week, or the date
Calendar date
A date in a calendar is a reference to a particular day represented within a calendar system. The calendar date allows the specific day to be identified. The number of days between two dates may be calculated. For example, "24 " is ten days after "14 " in the Gregorian calendar. The date of a...

. It is available on all Windows NT
Windows NT
Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...

-based operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s produced after Windows 2000 (NT 5.0) with the exception of Windows XP Home and Starter Editions.

Each command is given a Security Identifier
Security Identifier
In the context of the Microsoft Windows NT line of operating systems, a Security Identifier is a unique name which is assigned by a Windows Domain controller during the log on process that is used to identify a subject, such as a user or a group of users in a network of NT/2000...

 (SID) which is assigned at the time of the task's creation. The SID is a Unique ID which is long enough to ensure no duplicates will occur. All unfinished or repeating jobs are reloaded at boot
Booting
In computing, booting is a process that begins when a user turns on a computer system and prepares the computer to perform its normal operations. On modern computers, this typically involves loading and starting an operating system. The boot sequence is the initial set of operations that the...

 time, with the same SIDs unlike at
At (Windows)
at is a command which schedules other commands to be run at a certain time. It may run a command once, or repeatedly based upon the day of the week, or the date. It is available on all Windows NT-based operating systems....

 jobs which use sequential numbering, and can change at boot-time.

Scheduled tasks are not run if the computer is turned off at the time, or is in sleep mode
Sleep mode
Sleep mode refers to a low power mode for electronic devices such as computers, televisions, and remote controlled devices. These modes save significant electrical consumption compared to leaving a device fully on and idle, but allow the user to avoid having to reset programming codes or wait for a...

 or in hibernation. The Scheduler service must also be running.

Usage

By itself, schtasks gives a list of all pending jobs. By using /query and additional options more details of specific tasks are displayed.

To shut down
Shutdown (computing)
To shut down or power off a computer is to remove power from a computer's main components in a controlled way. After a computer is shut down, main components such as CPUs, RAM modules and hard disk drives are powered down, although some internal components, such as an internal clock, may retain...

 a computer
Personal computer
A personal computer is any general-purpose computer whose size, capabilities, and original sales price make it useful for individuals, and which is intended to be operated directly by an end-user with no intervening computer operator...

 at 10:00 in the evening:
schtasks /Create /TN Shutdown /ST 22:00 /TR "shutdown -s"
The above example will cause a scheduled task to be created named 'Shutdown' which will cause shutdown.exe to shut down the computer the next time the computer's clock reads 10pm. Note unlike 'at' the time must be given in HH:mm (24 hour time). Also Note that shutdown.exe is in one of the folders (normally C:\Windows\System32) listed in the %PATH%
Path (variable)
PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located...

 environment variable
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

. Other commands will require the full file path.)

Commands can also be scheduled on other computers on a local-area network, using a remote procedure call
Remote procedure call
In computer science, a remote procedure call is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space without the programmer explicitly coding the details for this remote interaction...

 (RPC). However, the user must be an administrator, have permission on the other machine, and the user account on both machines must have a password
Password
A password is a secret word or string of characters that is used for authentication, to prove identity or gain access to a resource . The password should be kept secret from those not allowed access....

 (RPC will refuse if passwords are blank). The UNC computer name is placed immediately after schtasks /Create using /S ComputerName, and must be followed by /U Username and /P Password in order to do this, as follows:
schtasks /Create /S \\OtherComputer /U RemoteUser /P RemotePassword /TN Shutdown /ST 22:00 /TR "shutdown -s"
The shutdown command is then scheduled on the remote computer named "OtherComputer" (not locally), and will show in its list of jobs. A remote computer's jobs can also be checked as follows:
schtasks /S \\OtherComputer

Flags

Several Base flag
Flag (computing)
In computer programming, flag can refer to one or more bits that are used to store a binary value or code that has an assigned meaning, but can refer to uses of other data types...

s greatly expand the usefulness of schtasks All Base flags come before the command being scheduled. However after a base flag is given there are often additional flags which can be used before or after the task name.

Base Flag /Create has many associated sub flags some of which are shown below:

The /SC Flag Specifies the schedule frequency. Valid schedule types: MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT can be used to repeat a command at the same event occurrence, such as time of day, day of the week, week of the month or year, month of the year, log on, log off, or other system event.

The /MO Flag Refines the schedule type to allow finer control over schedule recurrence. But relies on further codes such as /D to allow for this

The /D Flag Specifies the day of the week to run the task. Valid values: MON, TUE, WED, THU, FRI, SAT, SUN and for
MONTHLY schedules 1 - 31 (days of the month). Wildcard "*" specifies all days.
schtasks /Create /TN Shutdown /SC WEEKLY /MO /D MON, TUE, WED, THU, FRI /ST 22:00 /TR "shutdown -s"
schtasks /Create /TN Shutdown /SC WEEKLY /MO /D SAT, SUN /ST 19:00 /TR "shutdown -s"

The above commands will shut down the computer at 10:00 PM (22:00) every weekday
Weekday
Weekday may either refer to only a day of the week which is part of the workweek thus not part of the weekend or to any of the days of the week.-Weekday as a day of the workweek:In most countries the days of the workweek are:# Monday# Tuesday# Wednesday...

 evening, and at 7:00 PM (19:00) every weekend
Workweek
The workweek and weekend are those complementary parts of the week devoted to labour and rest respectively. The legal working week , or workweek , is the part of the seven-day week devoted to labor. In most Western countries it is Monday to Friday. The weekend comprises the two traditionally...

 evening.

The Full List of Base flags is shown below:

The /? Flag Shows the general help screen when no other flags are specified, shows help listing all additional sub flags when used after a base flag
For example:
schtasks /? Shows What Base Flags are
schtasks /Run /? Shows What sub-flags apply to the /Run flag.

The /Run Flag Runs a previously scheduled command.

The /End Flag Stops a scheduled command which is already executing.

The /Create Flag Creates a new scheduled command.

The /Delete Flag Deletes a scheduled command.

The /Query Flag Lists scheduled command information.

The /Change Flag Changes the parameters of an existing scheduled command.

The /ShowSid Flag Will list the SID
Security Identifier
In the context of the Microsoft Windows NT line of operating systems, a Security Identifier is a unique name which is assigned by a Windows Domain controller during the log on process that is used to identify a subject, such as a user or a group of users in a network of NT/2000...

 of a given command, must be used in conjunction with the /TN Flag.

Replacement

Prior to Windows XP, and Windows 2003 server, the at
At (Windows)
at is a command which schedules other commands to be run at a certain time. It may run a command once, or repeatedly based upon the day of the week, or the date. It is available on all Windows NT-based operating systems....

was used to schedule commands via the command line; Although this command is not as powerful or flexible, it is far simpler to use, and still functions under later versions of windows NT. The Task Scheduler
Task Scheduler
Task Scheduler is a component of Microsoft Windows that provides the ability to schedule the launch of programs or scripts at pre-defined times or after specified time intervals. It was first introduced in the Windows 95 Plus! pack as System Agent but was renamed to Task Scheduler in Windows 98...

 is the graphical user interface
Graphical user interface
In computing, a graphical user interface is a type of user interface that allows users to interact with electronic devices with images rather than text commands. GUIs can be used in computers, hand-held devices such as MP3 players, portable media players or gaming devices, household appliances and...

to schtasks, and at jobs will show in the task lists of both programs.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK