GUI is very popular due to its simplicity and ease of access. But when it comes to managing or automating Windows services, CLI is simply superior and more efficient if you are used to using it.
To stop a Windows service through Command-Line, you can use the Stop-Service
cmdlet in PowerShell or the Net stop
command in CMD.
We’ve provided step-by-step guidelines on how to do so below.
How to Stop a Windows Service From Command Line
In addition to the commands mentioned above, you can also use the Set-Service
cmdlet in Powershell or theSc stop
command in CMD to stop a Windows Service.
Using PowerShell
Before going to the actual process, here’s what the commands do.
Get-Service
displays a list of all services on the computer.Stop-Service
is used to stop one or more running services.Set-Service
can change the properties of a service, including the Status and StartupType.
- Press Windows + X and then press A to open Windows PowerShell (Admin).
- Type and enter
Get-Service
to get a list of all services. - Type either of the following commands:
Stop-Service -Name “service-name-here”
Set-Service -Name “service-name-here” -Status stopped
Replace “service-name-here” with the Name or DisplayName from Step 2 and press Enter.
For e.g.Stop-Service -Name AJRouter
- Type
get-service “service-name-here“
to check if the service is stopped.
Stop-Service -Name “service-name-here” -Force
Set-Service -Name “service-name-here” -Status stopped -Force
Using Command Prompt
Sc queryex
obtains and displays detailed information about all active services by default. With the use of certain parameters, it can also show info on drivers, their state, and more.
Both Net stop
and sc stop
can stop a service. But Net only works locally while sc can be used over a network.
- Press Windows + R to launch Run.
- Type cmd and press CTRL + Shift + Enter to launch Elevated Command Prompt.
- Type
sc queryex state= all type= service
and press Enter to get a list of all the services. - Note the SERVICE_NAME and DISPLAY_NAME of the service you want to stop. You can replace “service-name-here” with either of these values in Step 5.
For Step 6, replace it with SERVICE_NAME specifically, as DISPLAY_NAME won’t work with thesc stop
command. - Type and enter
net stop “service-name-here”
. - Alternatively, type
sc stop “service-name-here”
and press Enter.
For e.g.sc stop spooler
Start/Restart Windows Service from Command Line
In Powershell, you can use the start-service
or restart-service
cmdlets as appropriate. As CMD doesn’t have a command to restart a service directly, we’ll combine the net stop
and net start
commands instead.
Powershell
Start-Service
starts one or more stopped services.Restart-Service
stops, then starts one or more services.
- Press Windows + X and press A to launch Windows PowerShell (Admin).
- Type
Get-Service
and press Enter to get a list of all services. - Note the Name and DisplayName of the service you want to start. Replace “service-name-here” with either of these values in the next step. Also, note the status.
- If the status is stopped, type the following command and press Enter:
Start-Service -Name “service-name-here”
- If the status is running, type the following command and press Enter:
Restart-Service -Name “service-name-here”
- Check the status of the service with the following command:
get-service “service-name-here”
Command Prompt
In CMD, you’ll have to stop the service first and restart it afterward. Otherwise, you’ll get a The requested Service has already been started error.
- Press Windows + R to launch Run.
- Type cmd and press CTRL + Shift + Enter to launch Elevated Command Prompt.
- Type
sc queryex state= all type= service
and press Enter to get a list of all the services. - Note the SERVICE_NAME and DISPLAY_NAME of the service you want to stop. You can replace “service-name-here” with either of these values in Step 5.
For Step 6, replace it with SERVICE_NAME specifically as DISPLAY_NAME won’t work with thesc start
command. - Type
net stop “service-name-here” && net start “service-name-here”
and press Enter. - Check the status of the service with the following command:
sc queryex “service-name-here”
Change Windows Service Startup Type from Command Line
You can use the Set-Service
cmdlet to change the startup type in Powershell. In Command Prompt, you can instead use the sc config
command.
Powershell
The acceptable values for the StartupType parameter are as follows:
- Automatic – The service starts automatically at system startup.
- AutomaticDelayedStart – The service starts automatically, slightly after other automatic services start.
- Manual – The service needs to be started manually by a user or program.
- Disabled – The service cannot be started.
- Press Windows + X to open the quick link menu.
- Press A and accept the prompt to launch Windows PowerShell (Admin).
- Type
Get-Service
and press Enter to get a list of all services. - Note the Name and DisplayName of the service you want to start. Replace “service-name-here” with either of these values in the next step.
- Type the following command, replace Automatic with the appropriate startup type, and press Enter:
Set-Service -Name “service-name-here” -StartupType Automatic
Command Prompt
The acceptable values for the start parameter are as follows:
- auto – The service starts automatically at system startup.
- delayed-auto – The service starts automatically at boot, but with a slight delay.
- demand – The service needs to be started manually by a user or program.
- boot – The boot loader loads the device driver.
- system – The device driver starts during kernel initialization.
- disabled – The service is disabled and won’t start.
- Press Windows + R to launch Run.
- Type cmd and press CTRL + Shift + Enter to launch Elevated Command Prompt.
- Type
sc queryex state= all type= service
and press Enter to get a list of all the services. - Note the SERVICE_NAME and DISPLAY_NAME of the service you want to stop. Replace “service-name-here” with either of these values in the next step.
- Type the following command, replace auto with the appropriate start option, and press Enter:
sc config “service-name-here” start=auto
How to Fix Can’t Stop Windows Service Because Of Access Denied System Error?
If you launch CMD/PowerShell without admin privileges and try to stop a Windows Service, you will encounter this error. To fix this, launch them in elevated mode, and you’ll be able to stop the service.