# Scheduled Tasks

Scheduled tasks are used to execute or do a certain action at a set period of time.

Scheduled tasks can be used for userland or elevated persistence. There is a lot of flexibility on how to configure and when to trigger the task, these can be checked issuing “schtasks.exe /?"

An example of this is this one, where it will run everyday at 10:00

```
schtasks /create /tn ”tenoclock" /tr C:\executable /sc daily /st 10:00
```

or when the user's session is idle for 10 minutes

```
schtasks /create /tn "NotEvil" /tr NotEvil /sc onidle /i 10
```

To execute as system, we can add the following flag: `/ru System`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kwcsec.gitbook.io/the-red-team-handbook/techniques/persistence/scheduled-tasks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
