Enumerating Tasks Example

To enumerate tasks, you must call ITaskScheduler::Enum to create an enumeration object. Then, use the enumeration object's IEnumWorkItems interface to enumerate the tasks in the Scheduled Tasks folder.

The following procedure describes how to enumerate the tasks in the Scheduled Tasks folder.

To enumerate the tasks in the Scheduled Tasks folder

  1. Call CoInitialize to initialize the COM library and CoCreateInstance to get a Task Scheduler object. (This example assumes that the Task Scheduler service is running.)
  2. Call ITaskScheduler::Enum to get an enumeration object.
  3. Call IEnumWorkItems::Next to retrieve the tasks. (This example tries to retrieve five tasks with each call.)
  4. Process the tasks returned. (This example simply prints the name of each task to the screen.
  5. Release resources. Call CoTaskMemFree to free the memory used for names.
For a code example of See
Enumerating all the tasks in the Scheduled Tasks folder of the local computer C/C++ Code Example: Enumerating Tasks

 

Task Scheduler 1.0 Examples