3.2.5.1.2 Starting a Task

First, the server MUST obtain the account name associated with the task as follows. For ATSvc tasks, the server MUST use the ATSvc account name. For SASec tasks, the server MUST obtain the account name from the account name store. For ITaskSchedulerService tasks, the server MUST obtain the account name from the UserId element of the XML task definition (section 2.5.6) if it is not the empty string, and use "LocalSystem" if it is not present or the empty string.

Next, the server MUST check the credential store for a mapping from the account name to a password. If a mapping is found, the server MUST use the password from the mapping to run the task. Otherwise, if the TASK_FLAG_RUN_ONLY_IF_LOGGED_ON flag is set in the task definition and the account name is logged on, the server MUST run the task using the logged-on account. Otherwise, the server MUST NOT run the task.

If the task is configured to run in system contexts (LocalSystem, NetworkService, LocalService), the server MUST run the task noninteractively and ignore any task configuration (section 2.5.6) to the contrary.

To run the task, the server MUST generate an instance ID and create an entry in the running task list that contains the instance ID, the location of the task in the task store, and sufficient information to stop the task. If the task's trigger has a delay (section 2.5.3), the entry state MUST be set to TASK_STATE_QUEUED, the entry delay MUST be initialized to the task's trigger delay, and the delay timer MUST be reset. Otherwise, the entry state MUST be set to TASK_STATE_RUNNING, the entry action MUST be set to the action to be executed (section 2.5.7), and the last runtime associated with the task in the task store MUST be set to the current time.

When the task finishes executing, the task stops as specified in section 3.2.5.1.3.