6. Creating New Tasks
Before you create a task, you should create a
new folder under the Task Scheduler Library to store the new task. To
create a new Scheduled Tasks folder, follow these steps:
1. | Select the Task Scheduler Library and either right-click and then select New Folder or click New Folder in the Actions pane.
|
2. | Enter the name of the new folder and click OK to complete creation of the new subnode.
|
3. | Select the new folder to start creating a new task.
|
You can create tasks by using the Create Basic
Task Wizard, or by manually using the Create Task interface. To create a
new task using the Create Basic Task Wizard, follow these steps:
1. | Right-click
the folder you created to store your tasks and select Create Basic Task
to display the Create Basic Task Wizard, or select Create Basic Task in
the Actions pane.
|
2. | Enter the name of the task, provide an optional description, and then click Next.
|
3. | On
the Task Trigger page, specify when you want the task to start and then
click Next. Some choices may require additional information to further
define the trigger.
|
4. | On the Task Action page, specify an action for your task to perform and then click Next to specify action details.
|
5. | Options displayed on the next page depend on the action you selected on the previous page.
|
6. | After specifying the appropriate action details, click Finish to create the task and close the wizard.
|
To create a new task manually, follow these steps:
1. | Select
the folder that the task will reside in and either right-click the
folder and select Create Task or select Create Task in the Actions pane.
Either action will display the Task Properties dialog with several tabs
for the different task details. The General tab defines general
information about the task:
|
2. | In the Name text box, enter a name for the task.
|
3. | In the Description text box, you can enter an optional task description or leave the box entry blank.
|
4. | Under Security options, select the appropriate options for the task:
- By default, the task will run under the security context
of the currently logged-on user. To select a different security context,
click Change User Or Group.
- Select either Run Only When
User Is Logged On or Run Whether User Is Logged On Or Not. If you
select Run Whether User Is Logged On Or Not and check the box Do Not
Store Password, the task will use S4U and will not be able to access any
resources outside the local computer.
- Select Run With
Highest Privileges if the task must run with the highest privileges that
the specified user account can obtain. If left unchecked, and if the
user account is an administrative account, the task will run under User
Account Control (UAC) with partial privileges.
|
5. | To
hide the task from view by default, select the Hidden check box. You
can still view hidden tasks by opening the View menu and selecting Show
Hidden Tasks.
|
6. | By
default, tasks are configured for Windows Vista, Task Scheduler
compatibility. For backward compatibility, the list allows you to select
Windows Server 2003, Windows XP, or Windows 2000 to define a task that
is compatible with Task Scheduler v1.0.
|
Defining Triggers
The Triggers tab shown in Figure 3
allows users to view and configure one or more triggers that will
launch the task. To define a new trigger, click the New button. To edit
an existing trigger, select the trigger in the list and click Edit. To
delete an existing trigger, select the trigger and click Delete.
In the New Trigger dialog, the Begin The Task
drop-down list allows you to configure a task to begin based on the
following trigger types:
The following sections explain trigger types and their corresponding settings in detail.
On A Schedule Trigger
The On A Schedule trigger configures the task
to start on a defined schedule. Selecting the On A Schedule trigger type
in the Begin The Task list displays the controls in the Settings group
box to configure schedule parameters. Table 2 describes these controls.
Table 2. On A Schedule Trigger Settings
Setting | Description |
---|
One time | Configures the task to run once at the specified date and time |
Daily | Configures the task to run on a schedule based on days |
Weekly | Configures the task to run on a schedule based on weeks |
Monthly | Configures the task to run on a schedule based on months |
Universal Time | Configures the task to run using UTC instead of the local time |
At Log On Trigger
The At Log On trigger allows you to define a
task to run when someone logs on to the computer. Selecting the At Log
On trigger type in the Begin The Task list displays the controls in the
Settings group box to configure schedule parameters. Table 3 describes these controls.
Table 3. At Logon Trigger Settings
Setting | Description |
---|
Any User | Configures the task to .start at logon of any user |
Specific User Or Group | Configures the task to start at logon of the specified user or group. |
<domain\user> | Read-only display of the currently selected user or group. |
Change User Or Group | Launches
the standard Windows Select User Or Group dialog box to allow the user
to change the selected user or group. If the user makes a different
selection in the dialog and clicks OK to accept, the <domain\user>
read-only text box should change to display the new selection. |
At Startup Trigger
This 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 later in this
section.
On Idle Trigger
The On Idle trigger configures the task to run
when the computer becomes idle.
On An Event Trigger
The On An Event trigger type allows a user to
define a task to execute on a specified Event Log event. To define the
event trigger, the Settings group box provides two options : the Basic
option allows for simple selection of a single event to be used as a
trigger (by choosing the log, source and event ID identifiers for the
event). The Custom option allows defining a more complex event filter by
providing the New Event Filter button. Click the button to launch the
Event Filter dialog (same as in Event Viewer) and define a more detailed
event filter by time, level, source and so on.
At Task Creation/Modification Trigger
Selecting the At Task Creation/Modification
trigger type in the Begin The Task list configures the task to start
immediately when it is created or modified. No other condition is
required and no further settings are displayed for this trigger.
On Connection To or Disconnect From User Session Triggers
The user session triggers cause a task to run
when a user session is connected to or disconnected 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 or disconnects to a user session or
when a specific user or user group member connects or disconnects.
Selecting the On Connection To User Session or
the On Disconnect From User Session trigger types in the Begin The Task
list displays the controls listed in Table 4 in the Settings group box.
Table 4. On Connection To or Disconnect From User Session Trigger Settings
Setting | Description |
---|
Any User | Configures the task to start when any user makes a connection to a user session. |
Specific User Or Group | Configures the task to start when the specified user or group makes a connection to a user session. |
<domain\user> | Read-only display of the currently selected user or group. |
Change User Or Group | Launches
the standard Windows Select User Or Group dialog box to allow the user
to change the selected user or group. If the user makes a different
selection in the dialog and clicks OK to accept, the <domain\user> read-only text box should change to display the new selection. |
Connection From Local Computer | Configures the task to start when the specified user connects locally. |
Connection From Remote Computer | Configures the task to start when the specified user connects remotely. |
On Workstation Lock or Unlock Triggers
Selecting the On Workstation Lock or the On
Workstation Unlock trigger type in the Begin The Task list displays the
controls listed in Table 5 in the Settings group box.
Table 5. On Workstation Lock and Unlock Trigger Settings
Setting | Description |
---|
Any User | Configures the task to start when any user locks or unlocks the workstation. |
Specific User Or Group | Configures the task to start when the specified user or member of the specified group locks or unlocks the workstation. |
<domain\user> | Read-only display of the currently selected user or group. |
Change User Or Group | Launches
the standard Windows Select User Or Group dialog box to allow the user
to change the selected user or group. If the user makes a different
selection in the dialog and clicks OK to accept, the <domain\user> read-only text box should change to display the new selection. |
Defining Actions
When you create a task, you must configure one
or more actions to run a program, script, or batch file, send an email
or pop up a message when your task starts. The Actions tab allows you to
define, view or modify actions for this task. To configure actions,
click the Actions tab and then click New to display the New Action
dialog, as shown in Figure 4.
To configure an action to start a program, script, or batch file, follow these steps:
1. | Open the Action list and then select Start A Program to display configuration options shown in Figure 4.
|
2. | In
the Settings group box, under Program/Script, provide the path to the
program or script or select Browse to choose a program, script, or batch
file on the local computer.
|
3. | If
the directory that contains the program, script, or batch file is not
included in the local computer path, enter the starting directory in the
Start In text box.
|
4. | If
the program, script, or batch file requires additional arguments to be
passed to it at launch, enter these arguments in the Add Arguments
(Optional) text box.
|
To configure an action to send e-mail, follow these steps:
Open the Action list and select Send An E-mail to display the configuration options:
In the Settings group box, enter the required information listed in Table 6.
Table 6. Send E-Mail Settings
Setting | Description |
---|
From | Specifies the e-mail address of the sender. |
To | Specifies
one or more e-mail addresses for recipients. When you enter multiple
addresses, separate each address with a semicolon (;). |
Subject | Specifies a subject for the e-mail. |
Text | Allows the user to enter a formatted message to be included in the content of the e-mail. |
Attachment | Displays a File Open dialog that allows the user to select one or more files to attach to the e-mail. |
SMTP Server | Allows the user to enter the DNS or NETBIOS name for the SMTP server to be used to send the e-mail. |
Note
To configure the task to
pop up a message, choose Display A Message in the Action drop-down
list, then enter a title and a message to be displayed when the task
runs. |
Defining Conditions
The Conditions tab displays different
conditions for running tasks and allows you to define settings for these
conditions. If you do not specify condition settings, designated
defaults will be applied to the task. Conditions on this page are
optional unless you have selected the On Idle trigger type. If you have
selected this trigger type, you must configure Idle settings as
described in this section.
1. | To configure task conditions, click the Conditions tab and configure the desired options as described in Table 7.
Table 7. Conditions OptionsSetting | Description |
---|
Idle | Groups all conditions related to idle that affect the starting of the task. | Start The Task Only If The Computer Is Idle For | Configures the task to start only if the computer has been idle for a certain amount of time. | Wait For Idle | Enabled
only by selecting the Start Only If Computer Is Idle For option;
configures how long to wait for the idle condition to be satisfied.
Options in the list include Indefinitely, 1 Minute, 5 Minutes, 10 Minutes, 15 Minutes, 30 Minutes, 1 Hour, and 2 Hours.
Default value: 30 Minutes
You can also enter other values using the following formats:
<ss> s[econds]
<mm>[:<ss>] m[inutes]
<hh>[:<mm>:<ss>] h[ours] | Stop If The Computer Ceases To Be Idle | Configures the task to stop if the computer ceases to be idle.
Default value: Checked | Restart If The Idle State Resumes | Enabled
only by selecting the Stop If Computer Ceases To Be Idle option.
Configures the task to restart if the computer re-enters the idle state.
Default value: Unchecked | Start The Task Only If The Computer Is On AC Power | Configures the task to start only if the computer is on AC power and not on battery power.
Default value: Unchecked | Stop If The Computer Switches To Battery Power | Configures the task to stop if the computer switches to battery power.
Default value: Unchecked | Wake The Computer To Run This Task | Specifies that the computer should be brought out of hibernation or standby to run this task.
Default value: Unchecked | Start Only If The Following Network Connection Is Available | Sets
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.
Default value: Unchecked |
|
Defining Settings
The Settings tab displays additional global
settings for the task and allows you to define these settings. All
settings on this page are optional. If you do not specify these
settings, designated default values will be applied to the task.
1. | To configure global settings using the Settings tab, click the Settings tab and configure the desired settings as described in Table 8.
Table 8. Global Settings Defined on the Settings TabSetting | Description |
---|
Allow Task To Be Run On Demand | Defines
whether the task supports Run Now functionality that allows tasks to be
run on demand from the user interface or command-line utilities.
Default value: Checked | Run Task As Soon As Possible After A Scheduled Start Is Missed | Configures
the task to run immediately if the service detects that a scheduled
activation was missed. For example, the computer was turned off when the
trigger condition occurred.
Default value: Unchecked | If The Task Is Already Running, Then The Following Rule Applies | Configures
action to be taken if the trigger for a task fires, while an instance
of that task is already running. Options include Do Not Start A New
Instance, Stop The Existing Instance, Run A New Instance In Parallel,
And Queue A New Instance.
Default value: Do not start a new instance | If The Task Fails | Use
this setting to restart a task if the task fails to run. (The last run
result of the task was not a success.) The user specifies the time
interval that takes place between task restart attempts and the number
of times to try to restart the task.
Default value: Unchecked | Restart Every | Enabled only by selecting the If Task Fails option. Specifies how often a retry should be attempted.
Options in the list include Indefinitely, 1 Minute, 5 Minutes, 10 Minutes, 15 Minutes, 30 Minutes, and 1 Hour
Default value: 1 Minute
You can also enter other values using the following formats:
<ss> s[econds]
<mm>[:<ss>] m[inutes]
<hh>[:<mm>:<ss>] h[ours] | Attempt To Restart Up To | Enabled
only if you select the If Task Fails option. Specifies the number of
times to restart the task upon failure (number of retries). | Stop The Task If It Runs Longer Than | Configures the task to stop if it has been running for longer than the specified time.
Default value: Checked | <Execution Time Limit> | Enabled
only if you select the Stop The Task If It Runs Longer Than check box.
Configures the task to be stopped after the specified amount of time
specified by Execution Time Limit. Options include 1 Hour, 2 Hours, 4
Hours, 8 Hours, 12 Hours, 1 Day, and 3 Days
Default value: 3 Days
You can also enter other values using the following formats:
<ss> s[econds]
<mm>[:<ss>] m[inutes]
<hh>[:<mm>:<ss>] h[ours] | If The Running Task Does Not End When Requested, Force It To Stop | If this setting is selected, the task will be forced to stop if the task does not respond to a request to stop.
Default value: Checked | If The Task Is Not Scheduled To Run Again, Delete It | Configures the task to be deleted if it is not scheduled to run again.
Default value: Unchecked | After | Enabled
only if you select the Delete Task option. Specifies the amount of time
to wait, after the task completes its last run, before deleting it.
Options include Immediately, 30, 90 180, or 365 days.
Default value: 30 Days
You can also enter other values using the following formats:
<ss> s[econds]
<mm>[:<ss>] m[inutes]
<dd> d[ays]
<mm> months |
|