Time Trigger Example (C++)

This C++ example shows how to create a task that is scheduled to execute Notepad at a specified time. The task contains a time-based trigger that specifies a start boundary and an end boundary for the task. The task also contains an action that specifies the task to execute Notepad. The task is registered using an interactive logon type, which means the task runs under the security context of the user who runs the application. The task also contains idle settings, which specifies how Task Scheduler performs tasks when the computer is in an idle condition.

The following procedure describes how to schedule a task to start an executable at a certain time.

Use the ITriggerCollection::Create method (specifying the type of trigger you want to create) to create a time-based trigger. This allows you to set the start boundary and the end boundary for the trigger so that the task's actions will be scheduled to execute at a specified time.

Use the IActionCollection::Create method to specify the type of action that you want to create. This example uses an IExecAction object, which represents an action that executes a command-line operation.