Windows Services

GUI

Launch from Start menu or by typing this at a command/Powershell prompt...

services.msc

msconfig

Check

Powershell

Get-Service

Get-Service -ComputerName myServer

Get-Service -Name SQLSERVERAGENT -RequiredServices

Get-Service -Name MSSQLSERVER -DependentServices

Lists Name and Display Name of all Services and their current Status

As above for a specified Computer

Lists other Services that the named Service is dependent on

Lists other Services that depend on the named Service

Get-Service -Name *MySQL*

Get-Service -DisplayName *MySQL*

Status   Name               DisplayName------   ----               -----------Running  MySQLRouter        MySQL Router

cmd

sc queryex | find "SERVICE_NAME" | find "MySQL"

SERVICE_NAME: MySQLRouter

sc queryex MySQLRouter

SERVICE_NAME: MySQLRouter        TYPE               : 10  WIN32_OWN_PROCESS        STATE              : 4  RUNNING                                (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)        WIN32_EXIT_CODE    : 0  (0x0)        SERVICE_EXIT_CODE  : 0  (0x0)        CHECKPOINT         : 0x0        WAIT_HINT          : 0x0        PID                : 1152        FLAGS              :

reg query HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\mysqlrouter

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\mysqlrouter    Type    REG_DWORD    0x10    Start    REG_DWORD    0x2    ErrorControl    REG_DWORD    0x1    ImagePath    REG_EXPAND_SZ    "C:\Program Files\MySQL\MySQL Router 8.0\bin\mysqlrouter.exe" -c "C:\ProgramData\MySQL\MySQL Router\mysqlrouter.conf" --service    DisplayName    REG_SZ    MySQL Router    ObjectName    REG_SZ    NT AUTHORITY\LocalService

sc qc mysqlrouter

[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: mysqlrouter        TYPE               : 10  WIN32_OWN_PROCESS        START_TYPE         : 2   AUTO_START        ERROR_CONTROL      : 1   NORMAL        BINARY_PATH_NAME   : "C:\Program Files\MySQL\MySQL Router 8.0\bin\mysqlrouter.exe" -c "C:\ProgramData\MySQL\MySQL Router\mysqlrouter.conf" --service        LOAD_ORDER_GROUP   :        TAG                : 0        DISPLAY_NAME       : MySQL Router        DEPENDENCIES       :        SERVICE_START_NAME : NT AUTHORITY\LocalService

Start/Stop/Restart a Service

This can be done via the GUI or...

Powershell

Start-Service -Name MSSQLSERVER

Restart-Service -Name MSSQLSERVER -Force

The -force flag is required because SQLSERVERAGENT is a dependent of MSSQLSERVER

Restart-Service -Name SQLSERVERAGENT

Stop-Service -Name MSSQLSERVER

Stop-Service -Name *SQL*

Killing an unresponsive service

Find your service name... You can do this by clicking Properties in the Services GUI or by using something based on the examples below...

sc queryex | find "SERVICE_NAME" | find "SQL"


Get-Service -Name *SQL*

Powershell

Find the PID of the service...

sc queryex MSSQLSERVER

KIll the Service...

taskkill /pid 999 /f

Bibliography