Windows Vista Task Scheduler
Published: March 3, 2006
The ability to perform actions based on an event occurrence enables proactive, ad-hoc system management. IT professionals can now configure machines to automatically react to potential system problems, including intermittent, hard-to-reproduce failures. They can also set up more complex and demanding tasks to run in sequence or in response to multiple triggers and condition changes. A task can notify an IT professional of a problem on a desktop by e-mail, and it can launch a diagnostic program or even an automated resolution.
For periodic routine administrative tasks, Windows Vista Task Scheduler allows IT specialists to define their daily tasks to run even when the machine is in standby or hibernate. Task Scheduler wakes the machine to run the tasks and allows it to return to standby or hibernation when the task is complete, saving energy while still ensuring that critical tasks run on time.
On This Page
In today's cost-conscious environment, IT professionals must ensure the reliable operation of an increasing number of client machines. For these machines to operate smoothly, standard programs such as backup software, virus scans, and disk defragmentation must run predictably and reliably. Strict Service Level Agreements (SLAs) make it critical for IT professionals to respond quickly to system events, provide proactive support, and work to avoid data loss.
Task Scheduler in Windows Vista greatly expands on the Scheduled Tasks tool in previous versions of Windows. It provides the flexibility administrators need to automate common desktop administrative tasks more reliably and more securely, making it easier to support an expanding number of client machines. The improvements in this tool open the door to an entire class of uses that have never before been possible.
Running automated standard desktop tasks can benefit businesses in numerous ways. Support costs can go down, data loss is minimized, and programs run as expected more often. Client machines operate in a more secure and robust fashion, freeing IT staff members to work on issues that add business value.
This white paper will provide an overview of the new features in Windows Vista Task Scheduler, including automatic responses to events and system conditions; scheduling, monitoring, and managing tasks; and improvements in reliability and security. It will also describe ways IT professionals can use the Task Scheduler to manage desktops more effectively.
Top of page
Task Scheduler defines a task as the unit of operation. A task consists of launching conditions, including triggers, conditions, and settings, and one or more execution operations, known as actions.
Triggers are sets of criteria that, when met, cause a task to be executed. Triggers can be time-based and event-based, specifying task start times, repetition criteria, and other parameters.
Conditions are used to restrict a task to run only if the machine is in a given state. A task will launch when a trigger is met only if all of the conditions on the task are true. For example, you can use conditions to launch a program when an event occurs only if the network is available, or to launch an action at a specific time only if the machine is idle.
Settings provide execution options. For example, settings can be used to indicate how often to retry an action.
Actions are the commands to be executed when the triggers and conditions are met. For example, an action can launch a program or send an e-mail.
Top of page
Task Scheduler pre-Vista
Though the version of Task Scheduler available in Windows XP and Windows Server 2003 offers many benefits for periodic scheduled administrative tasks, it has limitations in the areas of reliability, security, and monitoring and control execution.
A major reliability obstacle in Windows XP was credentials management. Because credentials for tasks were stored locally, any update in domain or local passwords could invalidate tasks. Periodic password changes are the norm in most enterprises, so IT professionals were forced to update credentials on each and every task on a regular basis.
During the security hardening of Windows Server 2003, a number of potential vulnerabilities required Microsoft to restrict the use of the Task Scheduler service to administrators only, reducing the number of scenarios for which it could be useful.
In case of a task execution failure, feedback was provided by means of a message displaying the error code of the last executed task. If multiple executions occurred before the Task Scheduler control panel applet could be accessed, all but the final error code was lost, with no means of easy retrieval. A task history was not maintained.
Prior to Windows Vista, Task Scheduler could be configured to launch only a single action in a scheduled task. IT professionals were unable to define sequences of actions, but instead had to determine how long each process in a sequence of operations would take, and "estimate" the right window of time between tasks to ensure completion of the previous one before starting the next. This lack of flexibility could cause a task to run incorrectly or not at all, as in the case of a reporting application failing to execute due to a reporting data collection task not being completed on time.
Finally, prior to Windows Vista, Task Scheduler could be used only to launch tasks at a certain time or in response to a limited set of system conditions (Figure 1). Tasks could not be triggered based on events, therefore the Task Scheduler was limited to periodic execution of scheduled tasks.
Scheduler was limited to periodic execution of scheduled tasks.
Top of page
Windows Vista enhancements and new features
Windows Vista is able to schedule jobs to run at specified times more predictably, reliably, and securely. But the Windows Vista Task Scheduler goes beyond simply scheduling the tasks; new features in Task Scheduler also fulfill the need for more complex and proactive system and application management, especially task synchronization and activation on event. The Windows Vista Task Scheduler provides a platform for easy, secure ad-hoc management of client machines.
New Triggers. The ability to trigger a task based on any event captured in the event log is one of the most powerful new features of the Windows Vista Task Scheduler. This new capability allows administrators to send an e-mail or launch a program automatically when a given event occurs. And it can be used to automatically notify a support professional when a critical event—for example, a potential hard drive failure—occurs on a client machine. It also enables more complex scenarios, such as chasing down an intermittent problem that tends to manifest overnight. Task Scheduler can be configured to notify an administrator by e-mail that a problem has occurred. An administrator can also use Task Scheduler to automatically launch a program to collect more data when the error occurs.
Setting up tasks to launch when events occur is easy with the new Task Scheduler Wizard in Windows Vista (Figure 2). An administrator can simply select the task in the Event Viewer to be used as a trigger and, with one click, launch the Task Scheduler Wizard to set up the task. The seamless integration between the Task Scheduler user interface and the Event Viewer allows an event-triggered task to be created with just five clicks.
In addition to events, the Task Scheduler in Windows Vista supports a number of other new types of triggers, including triggers that launch tasks at machine idle, startup, or logon. A number of additional triggers allow administrators to set up tasks to launch when the session state changes, including on Terminal Server connect and disconnect and workstation lock and unlock. Task Scheduler still allows tasks to be triggered based on time and date, and provides easy management of regularly scheduled tasks.
In the new Task Scheduler, triggers can be further customized to fine tune when tasks will launch and how often they will run. An administrator can add a delay to a trigger, or set up a task to repeat at regular intervals after the trigger has occurred. Administrators can also set limits on tasks, indicating that the task must stop running after a given period of time. Activation and expiration dates can also be specified.
Figure 3 illustrates the controls available for creating and customizing triggers using the Create New Trigger dialog. This dialog can be used to set up a new trigger or customize an event trigger created by the Task Scheduler Wizard.
Conditions and Settings. The combination of triggers, conditions, settings, and actions provides a powerful and extensive activation model.
A number of conditions can be defined for each task. Conditions are used to restrict a task to run only if the machine is in a given state. For example, with the new Task Scheduler, you can launch a program when an event occurs only if the network is available, launch an action at a specific time only if the machine is idle, or launch an action at logon only if the computer is not operating in battery mode.
In Windows Vista, administrators can define conditions based on the idle state of the computer, the power source of the computer (AC versus batteries), network connectivity, and the power state of the computer ("ON" versus in a sleep state). For example, tasks can be set to run only when the computer is operating on AC power, to stop if the computer starts running on battery power, or to run only if the computer is connected to the network. Perhaps most importantly, a task can be configured to awaken the computer from hibernation or standby to run a task. Figure 4 shows the dialog for setting conditions on a task.
Administrators can use settings to instruct Task Scheduler what actions to take if a task fails to run correctly. In case the task fails, administrators can indicate how many times to retry it. If the computer is not powered on when a task is scheduled, an administrator can use settings to ensure that the task will run as soon as the machine is available. An administrator can also define a maximum execution time for a task, ensuring that the task will time out if it runs too long.
The Settings dialog (Figure 5) provides execution options, like stopping tasks if they take too long or retrying them should they fail to run.
Flexible Actions and Triggers. Prior to Windows Vista, each task was launched based on a single trigger (usually the time), and a given task could include only one action. The Windows Vista Task Scheduler provides much greater flexibility in linking triggers to actions, allowing IT administrators to use this tool to easily manage more complex scenarios.
In Windows Vista, multiple triggers can be attached to a given task. For example, a given error condition might be indicated only if three different events occur. An administrator can easily define a task that will launch only if all three of these events occur.
Not only can tasks require multiple triggers, a single task can be used to launch multiple actions. Synchronized operations are now possible, through either multiple actions that run sequentially in a single task or by chaining tasks together using events fired by a previous task to launch the next task. This synchronization enables scenarios like checking the disk for failures first, running clean disk, compressing files, and finally backing up to a share. All of these operations can be completed using a single task.
The new Task Scheduler removes the guesswork from trying to run tasks in sequence. For example, suppose that every night at 1 a.m. an administrator needs to run a particular batch process and then print the results of the process when it completes. Prior to Windows Vista, the administrator would need two tasks to automate this process—one task launching at 1 a.m. to run the batch file, and a second task to print the results. The administrator would have to guess how long it would take the batch process to complete, and set up the print task to launch after an appropriate interval. If the batch process was not complete before the print process began—or failed to run altogether—the results would not be printed.
With Windows Vista, this scenario is easy to manage. A single task can be defined to run the batch process starting at 1 a.m. and print the results after the batch process completes. Figure 6 illustrates how an administrator can attach multiple actions to a single task.
Security. In the Windows Vista Task Scheduler, security is vastly improved. Task Scheduler supports a security isolation model in which each set of tasks running in a specific security context starts in a separate session. Tasks executed for different users are launched in separate window sessions, in complete isolation from one other and from tasks running in the machine (system) context. Passwords are stored (when needed) in the Credentials Manager (CredMan) service using encryption interfaces. Using CredMan prevents malware from retrieving the stored password, tightening security further.
In Windows Vista, the burden of credentials management in Task Scheduler has lessened. Credentials are no longer stored locally for the majority of scenarios, so tasks do not "break" when a password changes. Administrators can configure security services such as Service for Users (S4U) and CredMan, depending on whether the task requires remote or local resources. S4U relieves the need to store passwords locally on the computer, and CredMan, though it requires that passwords be updated once per computer, automatically updates scheduled tasks configured to run for the specific user with the new password.
Reliability. The Windows Vista Task Scheduler improves reliability and availability on multiple levels. First, Task Scheduler now includes an option to retry tasks in case of failure, allowing administrators the flexibility to specify the number of retries and the interval of time between tries.
Task Scheduler makes sure that tasks run even if a machine is in a sleep state when the task is scheduled. This new functionality, which allows Task Scheduler to wake the machine from standby or hibernate to run a task, lets administrators take advantage of the enhanced power-saving modes in Windows Vista without having to worry whether critical tasks will run on time.
In addition to being able to wake the computer to run a task, administrators can now specify an option to run a task when the computer becomes available. When this option is selected, Task Scheduler will run the task as soon as the computer is powered on if the scheduled task execution was missed. For example, if a virus scan was scheduled to run at 3 a.m., but the laptop was not powered on, Task Scheduler will execute the virus scan the next time the machine is turned on. Windows Vista gives IT professionals options for making sure critical tasks run as quickly as possible.
Performance. Task Scheduler in Windows Vista includes options to ensure that tasks will not affect system performance or interrupt critical work. IT professionals can set Task Scheduler to activate tasks only when the computer is idle. This feature, together with support for task prioritization, allows background operations to be launched non-intrusively.
Scripting and Command Line Options. Improving the user experience is one of the main goals of the Windows Vista Task Scheduler. For IT professionals that prefer to use a command line tool instead of GUI, the schtasks.exe command line utility has been extended to cover all the new functionality added for Windows Vista. The application programming interface (API) is now also scriptable.
Monitoring and Managing Tasks. Task Scheduler logs its execution status using a set of predefined events in the Event Log for the purposes of monitoring, synchronization, and health management. The newly redesigned user interface (provided as an MMC snap-in), allows detailed monitoring and control of the tasks through summary pages, tasks history, and detailed task views. The summary page (Figure 7) provides a quick overview of the tasks that executed in a configurable window of time and their pass/fail results, as well as all the tasks that are still active on the computer.
The history page (Figure 8) allows administrators to drill into all the instances of tasks that were executed during a configurable period of time. It provides information on their execution status, as well as the date and time they were run.
A detailed view of all scheduled tasks is provided in the Scheduled Tasks Details (Figure 9). The upper pane contains a list of tasks scheduled on the computer. The bottom pane shows details for the highlighted task in the list. Triggers, Actions, Conditions, and Settings for each task are viewable by clicking the tabs.
Top of page
Task Scheduler can help IT professionals work faster, smarter, and more securely. It offers greater flexibility in defining, scheduling, and automating standalone, repeated, or sequenced tasks. It responds proactively to error conditions. It is easy to access and easy to use. It provides a transparent, one-stop view into tasks and events in an enterprise system. In short, Windows Vista Task Scheduler is a dependable, powerful addition to the IT toolbox.