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.
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.
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
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.
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:
Command Prompt
The acceptable values for the start parameter are as follows:
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.