Setting Task Property Examples
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.
In the following code example, all interfaces are released after they are no longer needed.
The following procedure describes how to set a task property.
To set a task property
- 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.)
- Call ITaskScheduler::Activate to get the ITask interface of the task object. (Note that this example gets the "Test Task" task.)
- Call the appropriate ITask method to set the property you are interested in.
- 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|