Windows Vista/7 Task Scheduler

The Task Scheduler helps you schedule automated tasks that perform actions at a specific time or when a certain event occurs. It maintains a library of all scheduled tasks, providing an organized view of the tasks and a convenient point of access for managing them. From within the library, you can run, disable, modify, and delete tasks.

Purpose

The Task Scheduler enables you to automatically perform routine tasks on a chosen computer. The Task Scheduler does this by monitoring whatever criteria you choose to initiate the tasks (referred to as triggers) and then executing the tasks when the criteria is met.

Where applicable

The Task Scheduler can be used to execute tasks such as starting an application, sending an e-mail, or showing a message box. Tasks can be scheduled to execute:

  • When a specific system event occurs.
  • At a specific time.
  • At a specific time on a daily schedule.
  • At a specific time on a weekly schedule.
  • At a specific time on a monthly schedule.
  • At a specific time on a monthly day-of-week schedule.
  • When the computer enters an idle state.
  • When the task is registered.
  • When the system is booted.
  • When a user logs on.
  • When a Terminal Server session changes state.

Triggers and Actions

The two key concepts involved in scheduling a task are triggers and actions. A trigger causes a task to run and an action is the work that is performed when the task is run. The actions a task can perform include running a program, sending an e-mail message, and showing a message box. For example, you can send an e-mail when a certain event entry is logged in the event log or run a maintenance script when a user logs on to a computer. Occurrences that can trigger a task to run include: a computer starting up, a computer entering an idle state, or a user unlocking a workstation. In addition, you can schedule a task to run at a specified time.

How to Start Task Scheduler

You can start the Task Scheduler MMC snap-in by using a single command from the command line or by using the Windows interface. Task Scheduler can also be started by double-clicking the Taskschd.msc file in the %SYSTEMROOT%\System32 folder.

To Run Task Scheduler using the Windows interface

  1. Click the Start button.
  2. Click Control Panel.
  3. Click System and Maintenance.
  4. Click Administrative Tools.
  5. Double-click Task Scheduler.

To Run Task Scheduler from the Command Line

  1. Open a command prompt. To open a command prompt, click Start, click All Programs, click Accessories, and then click Command Prompt.
  2. At the command prompt, type Taskschd.msc.

General Task Properties

The general properties of a task are displayed on the General tab of the Task Properties or Create Task dialog box. The general properties of a task include the task name, author, description, security options, the operating system that the task is configured for, and a property that controls whether the task is hidden.

When you create a task in a task folder, you must name the task. No two tasks can have the same name if they are in the same task folder. The task description is optional.

Task security options specify the security context that the task runs under.

By default, hidden tasks are shown in the Task Scheduler user interface (Show Hidden Tasks is selected in the View menu.) You make a task hidden when you click the Hidden check box on the General tab of the Task Properties or Create Task dialog box.

Task Configuration

Tasks configured for Windows Vista®/7 or Windows Server® 2008 have more functionality than the tasks configured for down-level systems (Windows Server 2003, Windows XP, or Windows 2000), and because of this, tasks configured for Windows Vista/7 or Windows Server 2008 will not work on down-level systems. Tasks configured for down-level systems will work on Windows Vista/7 or Windows Server 2008, but certain triggers, actions, conditions, and settings are only available on Windows Vista/7 or Windows Server 2008. Tasks configured for down-level systems do not display, in the Task Scheduler console window, the date and time that the tasks were created.

If a task is created on a computer running Windows Vista/7 or Windows Server 2008, and the task needs to be managed from a remote down-level system (Windows Server 2003, Windows XP, or Windows 2000), then configure the task for down-level systems. Otherwise, the task should be configured for Windows Vista/7 or Windows Server 2008.

Triggers Tab

When setting up a task, first decide what will trigger that task to start. A trigger is a set of criteria that, when met, starts the execution of a task. A task’s triggers are displayed on the Triggers tab of the Task Properties or Create Task dialog box. You can use a time-based trigger or an event-based trigger to start a task. Time-based triggers include starting a task at a specific time of day or starting a task multiple times on a daily, weekly, or monthly schedule. Event-based triggers start a task in response to certain system events. For example, event-based triggers can be set to start a task when the system starts up, when a user logs on to the computer, or when the computer enters an idle state. Each task can contain one or more triggers, allowing the task to be started in many ways. If a task has multiple triggers, the task will start when any of the triggers occur.

Trigger Settings

Each trigger contains settings that determine the criteria to activate the trigger. Additional advanced settings can be set for each trigger, which is explained in the Advanced Settings section below. The trigger settings are accessed from the Edit Trigger or New Trigger dialog box, which is viewed by clicking on the Edit or New button on the Triggers tab in the Task Properties or Create Task dialog box.

Triggers

The following list describes each trigger and the trigger settings.

  • On a scheduleThis trigger causes the task to run according to a schedule, and the trigger settings allow you to set the schedule. You can choose to schedule the task at one time, or on a daily, weekly, or monthly schedule. The time you set is relative to the time zone that is set on the computer that runs the task. Check the Universal check box to make the time relative to Coordinated Universal Time (UTC) instead of the time zone that is set on the computer that runs the task. Use the Universalsetting when you want to coordinate a set of tasks to run simultaneously in multiple time zones.If you select the One timeradio button, you choose a date and time to trigger the task.If you select the Dailyradio button, you choose the recurrence interval for the task and the date and time to start the task. An interval of 1 produces a daily schedule and an interval of 2 produces an every other day schedule. The task will start at the specified time each day.If you select the Weeklyradio button, you choose the recurrence interval for the task, the date and time to start the task, and the days of the week in which to start the task. An interval of 1 produces a weekly schedule and an interval of 2 produces an every other week schedule. The task will start at the specified time on each of the specified days.If you select the Monthly radio button, you choose the months in which you want to start the task and the weeks of the month and the days of the week for each month in which you want to start the task. You can also specify that you want to start a task on the last day of each month.
  • At log onThis trigger causes the task to run when a user logs on to the computer, and the trigger’s settings allow you to specify that the task should be triggered when any user logs on the computer or when a specific user logs on.
  • At startupThis trigger causes the task to run when the computer starts up. The only settings for this trigger are the advanced settings described in the Advanced Settings section below.
  • On idleThis trigger causes the task to run after the computer enters an idle state, and the idle settings can be set from the Conditions tab in the Create Task or Task Properties dialog box.
  • On an eventThis trigger causes the task to run when specific event entries are added to an event log. You can choose between specifying basic event trigger settings or custom event trigger settings. If you choose the basic event trigger settings, a single event from a specific event log will trigger the task. You choose the event log that contains the event, the event publisher name, and specify the event identifier. If you choose the custom event trigger settings, you can specify an XML event query or a custom event filter to query for events that will trigger the task.
  • At task creation/modificationThis trigger causes a task to run as soon as it is created and when the task is modified. The only settings for this trigger are the advanced settings described in the Advanced Settings section below.
  • On connection to user sessionThis trigger causes a task to run when a user session is connected to from the local computer or from a remote desktop connection. For example, when you connect to a user session on the local computer by switching users on the computer, this trigger will cause the task to run. Another example that can trigger a task to run is when a user connects to a user session by using the Remote Desktop Connection program from a remote computer. The trigger’s settings allow you to specify that the task should be triggered when any user connects to a user session or when a specific user connects.
  • On disconnect from user sessionThis trigger causes a task to run when a user session is disconnected from the local computer or from a remote desktop connection. For example, when you disconnect from a user session on the local computer by switching users on the computer, this trigger will cause the task to run. Another example that can trigger a task to run is when a user disconnects from a user session by using the Remote Desktop Connection program from a remote computer. The trigger’s settings allow you to specify that the task should be triggered when any user disconnects from a user session or when a specific user disconnects.
  • On workstation lockThis trigger causes the task to run when the computer is locked. The trigger’s settings allow you to specify that the task should be triggered when any user locks the computer or when a specific user locks the computer.
  • On workstation unlock

    This trigger causes the task to run when the computer is unlocked. The trigger’s settings allow you to specify that the task should be triggered when any user locks the computer or when a specific user locks the computer.

Advanced Settings

The following list describes the advanced trigger settings.

  • Delay task for or Delay task for up to (random delay): This setting allows you to specify an amount of time to delay the task from running, after the task is triggered. If you are using a time-based trigger (On a schedule), then the delay time will be a random time between the time the task is triggered and the time specified in this setting. If a task is scheduled to be triggered at 1:00 pm, and the Delay task for up to (random delay) setting is set to 5 minutes, then the task will run sometime between 1:00 pm and 1:05 pm.
  • Repeat task every: This setting allows you to set a repetition time interval for the task. The task will run, wait for the time interval specified, and then run again. This cycle will continue until the duration time is met.
  • Stop any task that runs longer than: This setting allows you to stop long running tasks by setting a time limit on the amount of time the task is allowed to run (execute the action).
  • Activate: This setting allows you to set a date and time to activate the trigger. Once a trigger is activated, the trigger can cause the task to run. The time is relative to the time zone that is set on the computer that runs the task. Check the Universal check box to make the time relative to Coordinated Universal Time (UTC) instead of the time zone that is set on the computer that runs the task. Use the Universal setting when you want to coordinate a set of tasks to activate simultaneously in multiple time zones.
  • Expire: This setting allows you to set a date and time for the trigger to expire. When a trigger is expired, it cannot cause the task to run. The time is relative to the time zone that is set on the computer that runs the task. Check the Universal check box to make the time relative to Coordinated Universal Time (UTC) instead of the time zone that is set on the computer that runs the task. Use the Universal setting when you want to coordinate a set of tasks to expire simultaneously in multiple time zones.
  • Enabled: This setting allows you to enable or disable the task. A task that is enabled can run, and a task that is disabled cannot run until it is enabled.

Actions Tab

A task action is the work that is performed when the task is run. A task can have a single action or a maximum of 32 actions. Each action contains settings that determine how the action is performed. A task’s actions are displayed on the Actions tab of the Task Properties or Create Task dialog box. When multiple actions are specified, they are executed in sequential order starting with the action at the top of the list in the Actions tab and ending with the action at the bottom of the list. You can change the order in which the actions are executed by selecting an action and clicking on the up or down arrow button to move the action in the list.

The following list contains a description of each action and the action settings.

  • Start a programThis action starts a program or script. In the Program/script text box, enter the name of the program or script you want to start. If the program or script takes command line arguments, you can supply these arguments in the Add arguments (optional) text box. In the Start in (optional) text box, you can specify the working directory for the command line that executes the program or script. This should be either the path to the program or script file or the path to the files that are used by the executable file. You can run any file like exe,mp3,pdf,doc,mkv,mp4,bat etc. Files like mp3,mp4,doc,pdf will be run on its default associated software. Say mp3 files will be run in Windows media player. You can run Windows CMD commands like taskkill,shutdown,ping,tracert,net,loggoff. For more CMD commands click http://ss64.com/nt/
  • Send an e-mailThis action sends an e-mail when a task is triggered. In the action settings you specify the e-mail address that the e-mail is from, the e-mail address that the mail will be sent to, the subject of the e-mail, the text in the e-mail message, and optional e-mail attachments. You must also specify the SMTP server that you use to send e-mail from.
  • Display a message

    This action shows a message box with a specified message and title. The action settings specify the text for the message box title and the text in the message. This action will only launch if the Run only if user is logged on security option is selected in the General tab of the Task Properties or Create Task dialog box.

Task Conditions Tab

Conditions control whether a task is run. A task will run if all of its conditions are met after the task is triggered to start. Conditions are split up into three categories: idle conditions, power conditions, and network conditions. A task’s conditions are displayed on the Conditions tab of the Task Properties or Create Task dialog box.

Idle Conditions

You can set a condition that tells the task to run only if the computer is in an idle state for a specific amount of time when a trigger is activated. When you set this condition, you also set the amount of time to wait (after the task is triggered) for the computer to enter an idle state.

The Task Scheduler service will check if the computer is in an idle state every 15 minutes. A computer is considered to be in an idle state when a screen saver is running. If a screen saver is not running, then the computer is considered to be in an idle state if there is 0% CPU usage and 0% disk input or output for 90% of the past fifteen minutes and if there is no keyboard or mouse input during this period of time. Once the Task Scheduler service detects that the computer is in an idle state, the service only waits for user input to mark the end of the idle state.

If a task is set to start only if the computer is idle for 30 minutes, and the task waits for the computer to be idle for 10 minutes, then the task will launch in 5 minutes only if the computer has been idle for 25 minutes prior to the time the trigger was activated. The task will not start if the computer enters an idle state 5 minutes after the trigger is activated.

If the Stop if the computer ceases to be idle condition is selected for a task and the task is running while the computer is in an idle state, then the task will stop running when the computer ceases to be idle. The task that is stopped by this condition will start running again the next time the computer enters an idle state if the Restart if idle state resumes condition is selected.

Power Conditions

You can set a condition that tells the task to run only if the computer is on AC power (not battery power) when the task trigger is activated. If this condition is set, you can also set a condition to stop the task if the computer switches to battery power. If both of these conditions are set for a task, then you have ensured that the task will only run when the computer is on AC power.

You can also set a condition that tells the task to wake the computer from sleep mode to run the task when the trigger is activated. Before you set the condition to wake the computer to run the task, ensure that the task will not cause the computer to wake at inconvenient times.

Network Conditions

You can set a condition to run the task only if a specific named network connection is available or if any network connection is available when the task’s trigger is activated. If your task action requires a network connection to execute, then set this condition.

Task Settings Tab

Task settings specify how a task is run, stopped, or deleted. A task’s settings are displayed on the Settings tab of the Task Properties or Create Task dialog box. The following list contains the descriptions of task settings.

  • Allow task to be run on demandYou can specify whether a task can be run manually before or after it is scheduled to run by allowing the task to be run on demand. The default setting allows a user to run the task at any time on demand.
  • Run task as soon as possible after a scheduled start is missedIf this setting is checked, the Task Scheduler service will start the task if the task was scheduled to run at a certain time, but for some reason (for example, the computer was turned off or the Task Scheduler service was busy) the task was not activated. The Task Scheduler service will not start the task immediately after the task was missed. By default the service waits ten minutes before starting the missed task.
  • If task fails, restart every:<time period>Use this setting to restart a task if the task fails to run (the last run result of the task is not a success). You specify the time interval that takes place between task restart attempts, and the number of times to try to restart the task.
  • Stop the task if it runs longer than:<time period>This setting allows you to limit the amount of time a task is allowed to run. Use this setting to limit tasks that might take a long period of time to execute, causing an inconvenience to the user.
  • If the task does not end when requested, force it to stopIf this setting is selected, the task will be forced to stop if the task does not respond to a request to stop.
  • If the task is not scheduled to run again, delete it after:<time period>If this setting is selected, the Task Scheduler service will automatically delete the task if it is not scheduled to run again. The Task Scheduler service will wait for the specified time period before deleting the task. If this setting is not selected, the Task Scheduler service will not automatically delete the task. The task must include at least one trigger with an expiration date in order to select this setting.
  • If the task is already running, then the following rule applies:You must specify how the Task Scheduler service should run the task if another instance of the task is already running:
    • Do not start a new instance: The Task Scheduler service will not run the new instance of the task and will not stop the instance that is already running.
    • Run a new instance in parallel: The Task Scheduler service will run the new instance of the task in parallel with the instance that is already running.
    • Queue a new instance: The Task Scheduler service will add the new instance of the task to the queue of tasks that the service will run, and the service will not stop the instance of the task that is already running.
    • Stop the existing instance: The Task Scheduler service will stop the instance of the task that is already running, and run the new instance of the task.

How to Schedule a Task

You can schedule a task by either creating a basic task using the Create Basic Task Wizard or by creating a task without the wizard and supplying task information in the Create Task dialog box. The procedures below describe how to create a task using either method. If you create a basic task using the Create Basic Task Wizard, most of the task properties will be set to their default values, and you choose a trigger for the task from the most commonly used triggers.

To create a basic task by using the Windows interface

  1. If Task Scheduler is not open, start Task Scheduler.
  2. Find and click the task folder in the console tree that you want to create the task in.
  3. In the Actions Pane, click Create Basic Task.
  4. Follow the instructions in the Create Basic Task Wizard.

To create a task by using the Windows interface

  1. If Task Scheduler is not open, start Task Scheduler.
  2. Find and click the task folder in the console tree that you want to create the task in.
  3. In the Actions Pane, click Create Task.
  4. On the General tab of the Create Task dialog box, enter a name for the task. Fill in or change any of the other properties on the General tab.
  5. On the Triggers tab of the Create Task dialog box, click the New… button to create a trigger for the task, and supply information about the trigger in the New Trigger dialog box.
  6. On the Actions tab of the Create Task dialog box, click the New… button to create an action for the task, and supply information about the action in the New Action dialog box.
  7. (Optional) On the Conditions tab of the Create Task dialog box, supply conditions for the task.
  8. (Optional) On the Settings tab of the Create Task dialog box, change the settings for the task.
  9. Click the OK button on the Create Task dialog box.

Task Scheduler Demo No. 1

In this case a software named “SRS Audio Essential” had settings to start automatically at boot. But it always crashed at windows startup because necessary windows services which is required to run this software had not started by that time. So the requirement was to delay the start of “SRS Audio Essential” by about 3 min at windows boot. By that time necessary windows services had started and when “SRS Audio essential” gets started after 3 min then there is no crashing.We will delay start the software “SRS Audio Essential” by 3 min at every Windows Vista/7 boot using Task Scheduler. First of all I removed the SRS audio essential from automatically start at boot because I am already scheduling to start after 3 min of booting process.

  • Right Click on Task Scheduler Window and Click on “Create new Task”.

  • In the “General” tab give “Name” field “SRS Audio Essential” . Fill “Description” field with description of task. In “Configure for:” select your operating system which in my case is “Windows 7”.

  • In the “Trigger” tab click on “New” button. A new window pops up named “New Trigger”. In “begin the task:” select “At startup”. In “Delay task for:” select “3 minute”. Note: you can edit the numbers manually in place of “x” in “x minute”,”x hour”,”x day”.

  • In the “Actions” tab click on “New” button. A new window pops up named “New Actions”. In “Action:” select “Start a program”. In “Program/script” select the location of the software SRS Audio essential.

  • In the “Conditions” tab

  • In the “Settings” tab

  • Click “OK”.

Task Scheduler Demo No. 2

We want to set an alarm to run at 6:00 AM every day.We will use Task Scheduler to run “alarm.mp3” file at 6:00 AM daily. You can use any other audio file in place of “alarm.mp3” which you want to run as alarm. This “alarm.mp3” file will be run by your default audio player.

  • Right Click on Task Scheduler Window and Click on “Create new Task“.

  • In the “General” tab give “Name” field “Alarm” . Fill “Description” field with description of task. In “Configure for:” select your operating system which in my case is “Windows 7”.
  • In the “Trigger” tab click on “New” button. A new window pops up named “New Trigger“. In “begin the task:” select “On a schedule“. In the “Setting” select “Daily“. In the “Start:” field select “6:00:00 AM“. Click “OK“.

  • In the “Actions” tab click on “New” button. A new window pops up named “New Actions“. In “Action:” select “Start a program“. In “Program/script” select the location of the “alarm.mp3” file. Click “OK”.

  • In the “Conditions” and “Setting” tab do the appropriate setting or you may  leave it as it is. Click “OK”.

You can do many more things with Task Scheduler and sorry that all cannot be covered here.