Task Actions

The work items performed by a task are called actions. A task can have a single action or a maximum of 32 actions. Be aware that when multiple actions are specified, they are executed sequentially.

Types of Actions

The following table of actions describes the type of work or actions that can be accomplished by a task.

Type of Action Description
ComHandler Action This action fires a COM handler.
Exec Action This action executes a command-line operation such as starting Notepad.
E-mail Action This action sends an email when a task is triggered.
Show Message Action This action shows a message box with a specified message and title.

Specifying Actions

The actions of a task are specified when the task is defined and stored in a collection of actions used by the Task Scheduler service. The following table lists links to reference topics for the APIs and XML elements that are associated with actions.

For more information and examples about how to use the Task Scheduler interfaces, scripting objects, and XML, see Using the Task Scheduler.

Interface APIs for C++ Development

API Description
Actions Property of ITaskDefinition Gets or sets the actions performed by the task.
IActionCollection Contains the actions performed by the task.
IComHandlerAction Represents an action that fires a handler.
IExecAction Represents an action that executes a command-line operation.
IEmailAction Represents an action that sends an email message.
IShowMessageAction Represents an action that shows a message box.

Scripting Object APIs for Scripting Development

API Description
TaskDefinition.Actions Gets or sets the actions performed by the task.
ActionCollection Contains the actions performed by the task.
ComHandlerAction Represents an action that fires a handler.
ExecAction Represents an action that executes a command-line operation.
EmailAction Represents an action that sends an email message.
ShowMessageAction Represents an action that shows a message box.

XML Elements

Element Description
Actions Defines the actions performed by the task.
ComHandler Represents an action that fires a handler.
Exec Represents an action that executes a command-line operation.
SendEmail Represents an action that sends an email message.
ShowMessage Represents an action that shows a message box.

Using Variables in Action Properties

Some action properties that are of type BSTR can contain $(Arg0), $(Arg1), ..., $(Arg32) variables in their string values. These variables are replaced with the values that are specified in the params parameter of the IRegisteredTask::Run and IRegisteredTask::RunEx methods or are contained within the event trigger for the task. The following table lists the action properties that can use variables in their string values.

Action Properties
COM Handler Action C++:
Scripting:
Email Action C++:
Scripting:
Exec Action C++:
Scripting:
Show Message Action C++:
Scripting:

About The Task Scheduler