# 2.15. Task scheduler

The `TaskService` is accessible via `windows.system.task_scheduler`

Note

See sample Scheduled tasks

Warning

This API have not been tested on real cases yet and may be subject to changes.

## 2.15.1. TaskService

class `windows.winobject.task_scheduler.``TaskService`

  Bases: `windows.generated_def.interfaces.ITaskService`

  The task scheduler

  `__call__`(name)

    Alias for `folder()`

  `create`(flags=0)

    Create a new `TaskDefinition` that can be used to create/register a new scheduled task

    Return type: | `TaskDefinition`

  `folder`(name)

    Return the `TaskFolder` with `name`

    Return type: | `TaskFolder`

  `root`

    The root `\` `TaskFolder`

  `value`

    current value

## 2.15.2. TaskFolder

class `windows.winobject.task_scheduler.``TaskFolder`

  Bases: `windows.generated_def.interfaces.ITaskFolder`

  A folder of tasks

  `__call__`(name)

    Alias for `folder()`

  `__delitem__`(name)

    Alias for `delete_task()`

  `__getitem__`(name)

    Alias for `get_task()`

  `create_folder`(name)

    Create a new sub-`TaskFolder` with `name`

  `delete_folder`(name)

    Delete the sub-folder with `name` in the current folder

  `delete_task`(name)

    Delete the task with `name` in the current folder

  `folder`(name)

    Return the `TaskFolder` with `name`

  `folders`

    The list of sub-folders

    Type: | `TaskFolderCollection`

  `get_task`(name)

    Retrieve the task with `name` in the current folder

    Return type: | `Task`

  `register`(name, taskdef, flags=_TASK_CREATION.TASK_CREATE(0x2L), userid=None, password=None, logonType=_TASK_LOGON_TYPE.TASK_LOGON_NONE(0x0L), ssid=None)

    Register the task definition `taskdef` as a new task with `name`

    Return type: | `Task`

  `tasks`

    The list of tasks in the folder

    Type: | `TaskCollection`

  `value`

    current value

## 2.15.3. Task

class `windows.winobject.task_scheduler.``Task`

  Bases: `windows.generated_def.interfaces.IRegisteredTask`

  A scheduled task

  `definition`

    The definition of the task

    Type: | `TaskDefinition`

  `enabled`

    `True` is the task is enabled

  `last_runtime`

    Gets the last time the registered task was last run.

  `name`

    The name of the task

  `next_runtime`

    Gets the next time the registered task will be run.

  `path`

    The path of the task

  `state`

    The state of the task

    Type: | `TASK_STATE`

  `value`

    current value

  `xml`

    The XML representig the task

    Type: | `str`

## 2.15.4. TaskDefinition

class `windows.winobject.task_scheduler.``TaskDefinition`

  Bases: `windows.generated_def.interfaces.ITaskDefinition`

  The definition of a task

  `actions`

    The list of actions of the task

    Type: | `ActionCollection`

  `principal`

    The principal that provides the security credentials for the task. These security credentials define the security context for the tasks that are associated with the principal.

    Type: | `TaskPrincipal`

  `registration_info`

    The registration information of the task

    Type: | `TaskRegistrationInfo`

  `triggers`

    The list of triggers of the task

    Type: | `TriggerCollection`

  `value`

    current value

  `xml`

    The XML representig the task definition

    Type: | `str`

### 2.15.4.1. TaskPrincipal

class `windows.winobject.task_scheduler.``TaskPrincipal`

  Bases: `windows.generated_def.interfaces.IPrincipal`

  Provides the security credentials for a principal. These security credentials define the security context for the tasks that are associated with the principal.

  `group_id`

    the user group that is required to run the task

  `id`

    the identifier of the principal.

  `logon_type`

    logon method that is required to run the task

    Type: | `TASK_LOGON_TYPE`

  `name`

    The name of the principal

  `run_level`

    the privilege level that is required to run the tasks

    Type: | `TASK_RUNLEVEL_TYPE`

  `user_id`

    the user identifier that is required to run the task

  `value`

    current value

### 2.15.4.2. TaskRegistrationInfo

class `windows.winobject.task_scheduler.``TaskRegistrationInfo`

  Bases: `windows.generated_def.interfaces.IRegistrationInfo`

  Provides the administrative information that can be used to describe the task.

  This information includes details such as a description of the task, the author of the task, the date the task is registered, and the security descriptor of the task.

  `author`

    The author of the task

  `date`

    The registration date of the task

  `description`

    The description of the task

  `documentation`

    Any additional documentation for the task

  `source`

    Where the task originated from.

    For example, a task may originate from a component, service, application, or user.

  `uri`

    the URI of the task.

  `value`

    current value

  `version`

    The version number of the task.

## 2.15.5. Action

### 2.15.5.1. Action

class `windows.winobject.task_scheduler.``Action`

  Bases: `windows.generated_def.interfaces.IAction`, `windows.winobject.task_scheduler.AbstractAction`

  Describe an action performed by a task

  `id`

    The action id

    Type: | `BSTR`

  `subtype`

    Return the `Action`-subtype according to `AbstractAction.type`

  `type`

    The type of action

    Type: | `TASK_ACTION_TYPE`

  `value`

    current value

### 2.15.5.2. ExecAction

class `windows.winobject.task_scheduler.``ExecAction`

  Bases: `windows.generated_def.interfaces.IExecAction`, `windows.winobject.task_scheduler.AbstractAction`

  Represent an action of type `TASK_ACTION_EXEC`

  `arguments`

    [R-W] The arguments for the command to execute

  `id`

    The action id

    Type: | `BSTR`

  `path`

    [R-W] The path of the programm to execute

  `type`

    The type of action

    Type: | `TASK_ACTION_TYPE`

  `value`

    current value

  `working_directory`

    The working directory for the command to execute

### 2.15.5.3. ComHandlerAction

class `windows.winobject.task_scheduler.``ComHandlerAction`

  Bases: `windows.generated_def.interfaces.IComHandlerAction`, `windows.winobject.task_scheduler.AbstractAction`

  Represent an action of type `TASK_ACTION_COM_HANDLER`

  `classid`

    The CLSID of the COM server executed

    Type: | `BSTR`

  `data`

    The DATA for the COM class

    Type: | `BSTR`

  `id`

    The action id

    Type: | `BSTR`

  `type`

    The type of action

    Type: | `TASK_ACTION_TYPE`

  `value`

    current value

## 2.15.6. Trigger

class `windows.winobject.task_scheduler.``Trigger`

  Bases: `windows.generated_def.interfaces.ITrigger`

  A task trigger

  `type`

    The type of trigger

    Type: | `TASK_TRIGGER_TYPE2`

  `value`

    current value

## 2.15.7. Collections

### 2.15.7.1. TaskFolderCollection

class `windows.winobject.task_scheduler.``TaskFolderCollection`

  Bases: `windows.generated_def.interfaces.ITaskFolderCollection`, `windows.winobject.task_scheduler.TaskCollectionType`

  `ITEM_TYPE`

    alias of `TaskFolder`

  `get_item`(index)

    Return elements nb `index`. Collection index starts at 1

  `items`

    Return the list of item in the collection

    Type: | `list`

  `value`

    current value

### 2.15.7.2. TaskCollection

class `windows.winobject.task_scheduler.``TaskCollection`

  Bases: `windows.generated_def.interfaces.IRegisteredTaskCollection`, `windows.winobject.task_scheduler.TaskCollectionType`

  `ITEM_TYPE`

    alias of `Task`

  `get_item`(index)

    Return elements nb `index`. Collection index starts at 1

  `items`

    Return the list of item in the collection

    Type: | `list`

  `value`

    current value

### 2.15.7.3. ActionCollection

class `windows.winobject.task_scheduler.``ActionCollection`

  Bases: `windows.generated_def.interfaces.IActionCollection`, `windows.winobject.task_scheduler.TaskCollectionType`

  `ITEM_TYPE`

    alias of `Action`

  `create`(action_type)

    Create a new action of type `action_type`

    Return type: | A subclass of `Action`

  `get_item`(index)

    Return elements nb `index`. Collection index starts at 1

  `items`

    Return the list of item in the collection

    Type: | `list`

  `value`

    current value

### 2.15.7.4. TriggerCollection

class `windows.winobject.task_scheduler.``TriggerCollection`

  Bases: `windows.generated_def.interfaces.ITriggerCollection`, `windows.winobject.task_scheduler.TaskCollectionType`

  `ITEM_TYPE`

    alias of `Trigger`

  `get_item`(index)

    Return elements nb `index`. Collection index starts at 1

  `items`

    Return the list of item in the collection

    Type: | `list`

  `value`

    current value