Setting Up a Tasks Trigger or Triggers
Tasks can be triggered in the following ways:
• At task creation or modification
• On connection to a user session
• On disconnection from a user session h
• On workstation lock
• On workstation unlock
You can establish zero, one, or several triggers for a task. If you don't set any triggers, you can still run the task on demand (unless you clear the Allow Task To Be Run On Demand check box on the Settings tab of the Create Task dialog box). This gives you a way to test a new task before committing it to a schedule, for example . If you set multiple triggers, the task runs when any one of the triggers occurs.
To set up a trigger, click the Triggers tab in the Create Task dialog box, and then click New. In the New Trigger dialog box that appears (shown in Figure 22-11), choose the type of trigger you want from the Begin The Task drop-down list.
- Figure 22-11 A task can have zero, one, or several triggers. Advanced Settings options let you set delay, repeat, and expiration parameters.
Note the Advanced Settings options at the bottom of the dialog box shown in Figure 22-11 .These choices—which let you establish delay, repeat, and expiration parameters (among other things)—are not so easy to find when you're reviewing a task that you or someone else has already created. They don't appear in the read-only version of a task's properties, and if you reopen the read/write version of the properties dialog box, you'll need to select a trigger (on the Triggers tab) and click Edit to see or change the advanced options
• Triggering a task on schedule Time-triggered tasks can be set to run once or to recur at regular intervals . The choices are probably self-explanatory, with the possible exception of the Synchronize Across Time Zones check box. Time triggers are governed by the clock of the machine on which the task is to run, unless you select this check box—in which case, they are triggered by Coordinated Universal Time (UTC). You might want to go with UTC if you're trying to coordinate time-triggered tasks on multiple machines in multiple time zones .
• Triggering a task at logon Logon tasks can be set for any user or a specific user or user group . If the user whose logon has triggered the task is not the user in whose security context the task is running, the task will be noninteractive—in other words, essentially invisible. (The user can note the presence of the task—and terminate it—by running Windows Task Manager, going to the Processes tab, clicking Show Processes From All Users, and answering the UAC prompt.)
• Triggering a task at startup If you set a task to be triggered at startup, the trigger takes effect when you start your own computer but before you log on . Therefore, if you intend for the task to run on your own system, be sure to choose Run Whether User Is Logged On Or Not on the General tab of the Create Task dialog box. Otherwise, the task will never run .
If you use the Change User Or Group button on the General tab to specify another user on your domain, and you choose Run Only When User Is Logged On, the startup-triggered task will run on the remote system when you restart your own, provided the specified user actually is logged on .
• Triggering a task on idle If you set a task to be triggered when your computer is idle, you should also go to the Conditions tab of the Create Task dialog box to specify what you mean by "idle ." For information about how Scheduled Tasks defines idleness, see "Starting and Running a Task Only If the Computer Is Idle" on page 788.
Note that you need to set an idle trigger on the Triggers tab only if idleness is the only trigger you want to use . If you're setting one or more other triggers but you want to ensure that the task starts only when the computer is idle, select Start The Task Only If The Computer Is Idle For on the Conditions tab and specify the time period in the field to the right.
• Using an event to trigger a task Anything that generates an item in an event log can serve as a task trigger. The simplest way to use this feature is to launch Event Viewer (Eventvwr.msc), find the event that you want to use as a trigger, right-click it in Event Viewer, and choose Attach Task To This Event. This action launches the Create Basic Task wizard, with the trigger portion of the wizard already filled out. The new task appears in a folder called Event Viewer Tasks (newly created for you if it doesn't already exist), and you can modify it if needed by selecting it there and opening its properties dialog box. See "Digging Deeper with Event Viewer" on page 825.
• Triggering at task creation or modification The option to trigger a task at task creation or modification gives you an easy way to make a task run the moment you finish setting it up the first time or editing it subsequently. You can use this setting for testing purposes, or by combining it with other triggers you can use it to make a task run immediately as well as subsequently.
• Triggering a task at user connection or disconnection The options On Connection To A User Session and On Disconnect From A User Session give you some flexible ways to set tasks running in response to user activities. Option buttons associated with these choices let you specify whether the settings apply to any user or to a particular user or group . Additional options make the trigger apply to remote connections and disconnections or to local connections and disconnections . Setting a trigger to a particular user on the local computer, for example, would enable you to run a task in response to that user's connection via Remote Desktop Connection or the Switch User command.
• Triggering a task at workstation lock or unlock Like several other triggering choices, the On Workstation Lock and On Workstation Unlock options can be configured to apply to a particular user or group or to anyone who locks or unlocks the computer.
Post a comment