> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run extractors in Windows Task Scheduler

> Run Cognite extractors in Windows Task Scheduler to start automatically on reboot, restart on failure, or run on a schedule.

Some of the Cognite extractors are distributed as a Windows service or as executable files. This article explains how you can run the Cognite extractors in **Windows Task Scheduler**. This is useful when you need to start the extractor when the machine reboots, restart the extractor if it terminates, or run the extractor on a schedule.

## Installing the extractor

Install the extractor in an installation directory where the executable file or Python program and dependencies are stored. The extractor can be instantiated in multiple deployments, for instance, one per source system. Each deployment requires a separate working directory to read configuration files, store state, and write logs.

<Info>
  You need [interactive sign-in permissions](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-authsod/bfc67803-2c41-4fde-8519-adace79465f6) to run a task.
</Info>

## Run as a service

The Windows Task Scheduler is an alternative to native Windows services. In this example, we'll use the Task Scheduler to run the OPC UA extractor executable file as a service.

### Before you start

<Steps>
  <Step title="Unzip the extractor">
    Unzip the extractor in an installation directory. For example: `C:\Cognite\opcua-extractor`.
  </Step>

  <Step title="Create a working directory">
    Create a working directory for the source system. For example: `AControlSystem`.
  </Step>

  <Step title="Configure the extractor">
    Open the *config* folder and configure `config.yml` based on the example file found in the same folder.
  </Step>
</Steps>

### Create a task

<Steps>
  <Step title="Create a basic task">
    Open the Task Scheduler, select **Create Basic Task** > enter a **name** > select **Next**.
  </Step>

  <Step title="Configure the trigger">
    In **Task Trigger**, select **When the computer starts**.
  </Step>

  <Step title="Set the action">
    In **Action**, select **Start a program**.
  </Step>

  <Step title="Configure the program">
    In **Start a Program**, insert the full path to the .exe file in **Program/script**, and add the working directory in **Start in**. Enter any command line arguments in **Add arguments**. For example, for PI extractor version 1.
  </Step>

  <Step title="Open properties dialog">
    In **Summary**, select **Open the Properties dialog for this task when I click Finish**, and then select **Finish**. Note that you can also modify properties later from the main window.
  </Step>

  <Step title="Configure general settings">
    On the **General** tab, select **Run whether user is logged on or not**.
  </Step>

  <Step title="Configure task settings">
    On the **Settings** tab, clear **Stop the task if it runs longer than** and, optionally, select **If the task fails, restart every:**.
  </Step>

  <Step title="Save the task">
    Select **OK** and if prompted, enter the password for the user. Save the task. The task is now listed under **Active tasks** in the main window:

    <Info>
      The status **Ready** indicates that a task is ready to start but not running.
    </Info>
  </Step>
</Steps>

### Start a task

To start a task, right-click and select **Run**, or select **Run** from the Actions pane.

## Run batch extractors on a schedule

<Steps>
  <Step title="Access trigger properties">
    Under **Action**, select **Properties** > **Triggers**.
  </Step>

  <Step title="Configure the schedule">
    Select **Edit trigger** and configure the schedule settings.

    <Tip>
      Enable **Stop the task if it runs longer than…**.
    </Tip>
  </Step>
</Steps>
