Setting Task Property Examples

To set the properties of a task, call ITaskScheduler::Activate to retrieve the interface of the task object, then call the appropriate ITask method to set the task property you are interested in.

The code examples listed at the bottom of the page show how to set the properties that are unique to task objects. For other work item properties that also apply to tasks, see Setting Work Item Property Examples.

Note

In the following code example, all interfaces are released after they are no longer needed.

 

In the following examples, the modified task object is always saved to disk by a call to IPersistFile::Save. (The IPersistFile interface is a standard COM interface inherited by the task object.)

The following procedure describes how to set a task property.

To set a task property

  1. Call CoInitialize to initialize the COM library and CoCreateInstance to get a Task Scheduler object. (These examples assume that the Task Scheduler service is running.)
  2. Call ITaskScheduler::Activate to get the ITask interface of the task object. (Note that this example gets the "Test Task" task.)
  3. Call the appropriate ITask method to set the property you are interested in.
  4. Call IPersistFile::Save to store the modified task object to disk.
For a code example of See
Setting the name of the application associated with a known task C/C++ Code Example: Setting Application Name
Setting the maximum run time of a known task C/C++ Code Example: Setting MaxRunTime
Clearing all command-line parameters associated with a known task C/C++ Code Example: Setting Task Parameters
This example sets the priority of a test task and then saves the task. This example assumes that the test task already exists on the local computer. C/C++ Code Example: Setting Task Priority
Setting the working directory of a known task C/C++ Code Example: Setting Working Directory

 

Task Scheduler 1.0 Examples