Service management
{back]
Use service manager MMC to connect from a remote client to get the normal GUI tool common to Windows users.
The alternative is to use sc CLI tool or scripting by using for example PowerShell. Both sc and PowerShell can be used either locally or remotely.
Query information from the command line
List status for all services locally:
sc query
sc \\computername query
Query status for a specific service:
sc query servicename
sc \\computername query servicename
The query option will only return basic information about the service without configuration options. To get the configuration part including startup type and dependencies:
sc qc servicename
PowerShell
List all services:
get-service
get-service -computername RemoteComputerName
Get status for a specific service:
get-service -name ServiceName | fl name,depend*require*,status
get-service -name ServiceName -computername RemoteComputerName
Get status for services that a service depends on:
get-service ServiceName -requiredServices
Get status for services depending on the current service:
get-service ServiceName -dependentServices
Sort services depending on status:
get-service n*|sort-object status -descending
Starting and stopping services from the command line
Starting and stopping services can locally be done by using net start servicename and net stop servicename. Skip the specific service name parameter for net start to list all running services.
A limitation of the net command is that it only handles the local machine. The remote option is however included in the sc command or by using powerShell.
sc \\servername start ServiceName
sc \\servername stop servicename
PowerShell
start-service -name servicename
start-service -name servicename -computername RemoteComputerName
stop-service -name servicename
restart-service -name servicename
Configuring services
Note that parameters for configuring services nead to have a space after '='-character.
Disable a service: sc config servicename start= disabled
Configure a service to start automatically: sc config servicename start= auto
Configure service dependencies: sc config servicename depend= dep1/dep2
PowerShell
set-service -name servicename -startuptype automatic
set-service -name servicename -startuptype disabled
set-service -name servicename -startuptype manual -computername RemoteComputerName