Task Scheduler 2.0
Task Scheduler 2.0
Task Scheduler enables you to schedule programs to run at a time you specify or when a specific event occurs, and can automatically perform routine tasks on a computer of your choice. Task Scheduler also monitors criteria you specify to initiate tasks and then executes those tasks when the criteria are met.
The redesigned Task Scheduler 2.0 is installed with Windows Vista® and Windows Server 2008. Task Scheduler 1.0 is installed with the Windows Server 2003 family, Windows XP, and Windows 2000 operating systems. This article highlights the new and enhanced features of Task Scheduler in Windows Vista.
Task Scheduler Before Windows Vista
Task Scheduler 1.0
During the security hardening of Windows Server 2003, Microsoft restricted the use of the Task Scheduler service to administrators only, which reduced the number of scenarios for which it could be useful.
In Windows XP, credentials for tasks are stored locally so any update in domain or local passwords can invalidate tasks. Periodic password changes are the norm in most enterprises, so IT professionals are forced to update credentials regularly on each and every task.
In earlier versions of Windows, if a task execution fails, feedback is provided by means of a message displaying the error code of the last executed task. If multiple executions fail—typically before the Task Scheduler Control Panel applet is accessed—all error codes except the last one are lost. Without an easy way to retrieve lost error codes, the task history is lost.
In earlier versions of Windows, Task Scheduler can be configured to launch only a single action in a scheduled task. It also is not possible to define a sequence of actions. An administrator has to determine how long each process in the sequence of operations will take and estimate the right amount of time between the tasks to ensure the previous task is completed before beginning the next. This lack of flexibility can cause a task to run incorrectly or not at all.
Also, earlier versions of Task Scheduler cannot be used to launch tasks based solely on events. Task Scheduler is limited to periodic execution of scheduled tasks.
The New Task Scheduler
Task Scheduler 2.0 Capabilities
Task Scheduler 2.0 in Windows Vista expands on the features and tools of the earlier versions. Task Scheduler provides several new functionalities and capabilities.
Task Scheduler now provides the ability to:
Send notification automatically about a problem on a local or remote computer by sending an e-mail to a specified address, and then launch a diagnostic program to resolve the problem.
Execute tasks unattended.
Launch tasks on a specified schedule, in response to an event or changes in the state of the system.
Perform an action based on an event that has been logged in an event log.
Configure machines to respond automatically to potential problems in the system.
Run tasks in sequence.
Run tasks in response to multiple triggers and system changes.
Define routine tasks to run even when a machine is in standby or hibernate mode. Task Scheduler wakes the machine from Hibernation or Standby and then runs the task.
New Features and Tools
Windows Vista provides new features and tools that make the work of IT administrators and software developers easier.
The following features are new in Task Scheduler 2.0:
Redesigned user interface
Credentials management using new security services
New user interface as an MMC snap-in
New task settings
Unlimited number of registered tasks
New scripting support
New Task Scheduler XML schema, which enables you to define a task using XML
The New MMC Snap-in User Interface
The Task Scheduler user interface and the Schtasks.exe command line tool (found in the %SYSTEMROOT%\System32 folder) have been redesigned to accommodate all the new Microsoft Management Console (MMC) features. The Scheduled Task wizard in previous versions of Windows is replaced in Windows Vista with a new MMC-compatible Task Scheduler application that can be run as a stand-alone application or as an MMC snap-in.
MMC is an extensible user interface that provides an environment for running management applications that are structured as components, and these components are called snap-ins.
The new user interface, provided as an MMC snap-in, enables you to monitor and control tasks through summary pages, task history, and detailed task views. The summary page of the MMC provides, in a configurable window, information about all tasks that have executed with the time and pass/fail status. The summary page also provides information about all tasks that are still active on the computer.
The following illustration shows the redesigned Task Scheduler Windows interface.
The following illustration shows the summary page for the Defrag task in the Task Scheduler Library.
For information about how to use the new MMC that ships with Windows Vista, see "Using MMC 2.0" in the MSDN Library at https://msdn.microsoft.com/library/.
Starting Task Scheduler from Windows Vista
You can start the Task Scheduler MMC snap-in by using a single command from the command line or by using the Windows interface.
To run Task Scheduler using the command line
Click Start, click All Programs, click Accessories, and then click Command Prompt.
At the command prompt, type Taskschd.
To run Task Scheduler using the Windows interface
Click Control Panel.
Click System and Maintenance.
Click Administrative Tools.
Double-click Task Scheduler to display the Task Scheduler 2.0 Windows interface.
Defining and Creating Tasks in Task Scheduler
With Task Scheduler, you can define tasks by selecting specific menus and create basic tasks with the help of wizards.
From the Action menu, you can select one of the following menus:
Connect to Another Computer
Create Basic Task
Display All Running Tasks
The following illustration shows the Create Basic Task Wizard, which can help you create a basic task, where a task named SendEmail is created with the wizard.
A trigger is a set of criteria that, when met, starts the execution of a task. Task Scheduler now provides new time- and event-based triggers that enable you to start tasks using multiple triggers for a single task.
Time-based triggers start tasks at specified times. The task can start once, at a specific time, or multiple times on a specific schedule. The schedule can be configured for daily, weekly, or monthly reoccurrence.
Event-based triggers start a task in response to events that occur in the system. For example, you can set event-based triggers to start a task when the system starts up, when a user logs on to the local computer, or when the system becomes idle.
The following illustration shows the Create Basic Task Wizard where the trigger "When the computer starts" is specified. That task will start when the computer starts.
Multiple triggers can start each task. This allows a single task to be started in any number of ways.
One of the most powerful new features of the Windows Vista Task Scheduler is the ability to trigger a task that is based on any event captured in the event log. This new capability enables you to send an e-mail notification to a person you specify, or launch a program automatically when an event occurs, or both. Task Scheduler now logs a task’s history in the event log and the log can be reviewed to find the status of a task.
Now with Task Scheduler in Windows Vista, besides the ability to attach multiple triggers to a given task, you can also launch multiple actions with a single trigger. If one event triggers multiple tasks, you can configure the tasks to run in parallel or in sequence.
For more information about triggers in Task Scheduler 2.0, see "Task Triggers" in the MSDN Library at https://msdn.microsoft.com/library/.
The following illustration shows the Create Basic Task Wizard that creates an action. The task will send an e-mail to the system administrator when the computer starts.
An action is the actual work that is performed by the task. Every task can specify one or more actions to complete its work. For example, an action can launch a program or send an e-mail. Also a task can have one or more actions. If you specify more than one action, they can execute sequentially. Task Scheduler 2.0 supports a maximum of 32 actions and provides more flexibility in linking triggers to actions. As a result, IT administrators easily can manage other, more complex tasks.
The following illustration shows the Create Basic Task Wizard with the "Send an e-mail" action specified. The task will send an e-mail to the system administrator when the computer starts.
The following illustration shows the Create Basic Task Wizard with the composed e-mail that will be sent to the Administrator (Admin@microsoft.com) when the computer starts.
You can also use a single task to launch multiple actions. You can specify either multiple actions that run sequentially in a single task, or you can chain tasks together with events fired by a previous task to launch the next task. For example, you can first check the disk on your machine for failures, run clean disk, compress files, and then back up your data. You can accomplish all these operations by defining a single task.
With the new Task Scheduler, you no longer have to guess when to begin tasks when running tasks in a sequence. For instance, you can schedule a task to run every night at 8 p.m. to process a batch file and then print the results of that process when it completes, and you do not have to guess when the batch process will complete. In previous versions of Windows, you need to schedule two tasks to automate this process―one task to launch at 8 P.P. to run the batch process, one to print the results―and you guess how long it will take the batch process to complete and specify the print task to launch after some appropriate interval. If the batch process does not complete before the print process is scheduled to begin or fails to run, the results also will fail to print.
For more information about the new actions, see "Task Actions" in the MSDN Library at https://msdn.microsoft.com/library/.
Credentials Management Using New Security Services
One of the major improvements in Windows Vista is security, and Task Scheduler is one of the tools that leverage the greater security. In Windows XP, credentials for tasks are stored on the local machine. Any update in domain or local passwords can invalidate tasks. When you change passwords regularly, you also have to update credentials on every task.
Task Scheduler in Windows Vista supports a new credential manager that forms part of the security isolation model. In this model, each set of tasks that runs in a specific security context starts in a separate session. Passwords are now stored in the Credentials Manager (CredMan) service. You can use encryption interfaces with CredMan to prevent malware from stealing stored passwords. You can also configure Service for Users (S4U), a security service that allows your task to run even if the password is changed. However, that task does not have access to password-protected resources, such as encrypted files and the credman password cache. This improves security and reduces maintenance related to password expirations in Task Scheduler.
New Task Settings
Task Scheduler uses settings to run the task with respect to conditions that are external to the task itself. Task settings specify how a task is run, stopped, or deleted. You can use task settings to:
Schedule what actions to take if a task fails to run.
Retry a task if it fails.
Specify how many times to retry a failed task.
Ensure that a task runs when the machine is powered on if the machine is powered off when a task is scheduled.
Specify a time when a task must time-out to prevent the task from running for too long.
Run a task as soon as possible after a scheduled start is missed.
Force a task to stop if it does not end when requested.
The following illustration shows the settings for the Defrag task in the Task Scheduler Library.
Unlimited Number of Registered Tasks
Task Scheduler 1.0 supports about one thousand registered tasks. The new Task Scheduler allows unlimited registered tasks.
New Scripting Support and APIs
Windows Vista provides new scripting objects that VB Script developers can use programmatically to access the functionalities available in Task Scheduler 2.0. Windows Vista also provides new Task Scheduler APIs, which C++ developers can use to customize their tasks. For more information about programming in XML, see Developing for Task Scheduler 2.0.
For information about Task Scheduler APIs, see "Task Scheduler Reference" in the MSDN Library at https://msdn.microsoft.com/library/.
Task Scheduler XML Schema
The Task Scheduler schema defines XML-formatted documents you can use to register tasks with the Task Scheduler service. Software developers now can create their own XML, validate it against this schema, and register tasks. If you define a task this way, Task Scheduler can import tasks already registered with the Schtasks.exe command line tool, or you can register tasks programmatically. Task Scheduler Schema defines several elements that you can use to read or write XML for a task. For more information, see Developing for Task Scheduler 2.0. For more information about Task Scheduler XML schema, see "Task Scheduler Schema" in the MSDN Library at https://msdn.microsoft.com/library/.
The new Task Scheduler is a dependable, powerful addition in Windows Vista. It provides controlled, unattended management of task execution, launched either on schedule or in response to events. Task Scheduler 2.0 also provides greater flexibility in automating stand-alone, repeated, and sequential tasks. Task Scheduler 2.0 is designed to provide the flexibility administrators need to automate common desktop tasks more reliably and securely.
Windows Management: A User's Perspective