Disable a Windows service from the command line
I want to disable a Windows service but I don't want to:
- Open the "Services" management console
- Scroll to the name of the service
- Right-click Properties (or double-click)
- Change the Startup Type: to disabled
- Apply
- Click "Stop"
I don't want to remove a Windows service but instead, just disable it.
sc config "Name of Service" start= disabled
sc stop "Name of Service"
The space after the "start=
" is important
You can see service name by double clicking a service on Services screen:
In addition to Kevin's answer, if you need to control more than one service, or select them based on some criteria, you can use wmic
.
Simple use to stop only 1 service (Sqlwriter in my example) would be:wmic service where name='SQLWriter' call ChangeStartmode Disabled
but the tool is much more powerful, for example to set disabled mode for all services with caption starting with SQL and not already disabled you could say:
wmic service where "caption like 'SQL%' and Startmode<>'Disabled'" call ChangeStartmode Disabled
SC STOP "<nameservice>"
SC CONFIG "<nameservice>" START=
( BOOT
, or SYSTEM
, or AUTO
, or DEMAND
, or DISABLED
, or DELAYED-AUTO
)
Link: Sc config