How to stop service from commandline in windows?

4

1

i would like to stop following services from command line

  • print spooler
  • shell harware detection
  • windows defender
  • windows update
  • onedrive onecloud

and also deny them from running at startup (as i set to disabled in mmc)

Failed to find an generic answer, so how to stop them from command lime .cmd file? Also, will it be required to run as admin?

xakepp35

Posted 2017-05-31T10:47:57.590

Reputation: 287

Also how could i stop arbitary service, given by its name? Some are specific executables, some are svchost and i cant just terminate it via process manager, as they could host over vital services. I event could not manage which svchost hosts what? – xakepp35 – 2017-05-31T10:52:51.557

Are they actually registry entries or what? Where did this random disease, called "services", sits? – xakepp35 – 2017-05-31T10:53:34.437

What do you mean by disease? And what OS are you using? – Jimmy_A – 2017-05-31T11:01:14.087

@D.A windows 10 x64 – xakepp35 – 2017-05-31T11:30:30.217

Answers

4

To stop a service use net stop <service name>

To start a service use net start <service name>

Both these need running from a elevated prompt.


To disable a service use sc config "Name of Service" start= disabled

This also needs running from a elevated prompt.


Finally, a list of services and their states is in the registry at:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

Or

You can type services.msc into cmd line and it'll give you a list

(Thanks @D.A !)

djsmiley2k TMW

Posted 2017-05-31T10:47:57.590

Reputation: 5 937

1You can just type Services in the task bar and get the list, no need to go into registry – Jimmy_A – 2017-05-31T11:03:46.747

1It might be noteworthy that not all services are visible using UIs, so going to the registry might be required to find specific system services or drivers. – Daniel B – 2017-05-31T11:21:22.030

1typing services into cmd doesn't work. From cmd it would be services.msc – LPChip – 2017-05-31T11:46:16.587

2

Interacting with services requires administrative privileges.

To view a list of installed services, type (this command does not require administrative privileges):

net start

Powershell can also be used, then it would be:

get-service | select Name

To start a service, type:

net start <name of service>

Or using powershell:

start-service -name <short name of service>
start-service -displayname <long name of service>

To stop a service, type:

net stop <name of service>

Or using powershell:

stop-service -name <short name of service>
stop-service -displayname <long name of service>

Note, services have a long and short name. For example: "Windows Update" is also known as wuauserv. Typing a service that contains a space needs to be quoted.

To modify the startup type of a service (example Automatic or disabled) use:

sc config "<name of service>" start=auto
sc config "<name of service>" start=disabled

Or using Powershell:

Set-Service -Name <short name of service> -StartupType automatic
Set-Service -DisplayName <long name of service> -StartupType disabled

The -name and -displayname obviously work for both setting the startup type to automatic and disabled, its just an example.

Given that you also mention Microsoft OneDrive, keep in mind that OneDrive is very stubborn and will likely be able to activate itself when you open the explorer. If you don't want to use OneDrive, consider going to start->Add/remove programs, and uninstall Microsoft OneDrive.

LPChip

Posted 2017-05-31T10:47:57.590

Reputation: 42 190

1

Two commands for killing services:

  1. net start to get a name list of running services
  2. net stop "name of service" to stop the service

A service is a programm almost like any other. The difference between services and other programs is that they run in the background and don’t have a user interface you can click or tap on. They are intended to provide core operating system features such as Web serving, event logging, file serving, printing or error reporting.

Not all services are developed by Microsoft. Some applications and drivers install their own services. Security suites are a very good example, as they install different services to provide real-time monitoring of your system’s activities, firewall protection, etc. These suites need to use the advantages provided by services. One such advantage is that they can be started during the system boot, before other programs and even before you log in. But the most important advantage is that they can monitor everything that runs on your computer while being perfectly integrated in the Windows core. This way, they can provide a very high level of protection.

Another example of a non-Microsoft service could be a SSH server, often used in offices for secure remote connections or an auto-updating service for your web browser like the Mozilla Maintenance Service.

Knowing what or when a service does something can be useful at times. For example, if you know you’re not going to need its features you can disable it to speed up your system. If you have a router installed to manage your local network, it’s likely that you don’t need the Internet Connection Sharing service to run. Or, if you need a service to run, but it’s not that important, you can set it to start a little bit later, after Windows, startup apps or other, more important services, have started. In my case, one of the services I need but my life doesn’t depend on it, is the Windows Time service, which synchronizes the date and time. So I decided to set it to a Delayed startup.

What is a Service? Definition of a Windows Service & Instructions on Controlling Services Understanding and Managing Windows Services

Jimmy_A

Posted 2017-05-31T10:47:57.590

Reputation: 972

service could not be always an application. it could be svchost.exe thread. And disease is non-uniformity of technology - some are apps, some are just threads, all random! it is not the way software must be developed, i require shut down requested services – xakepp35 – 2017-05-31T11:32:41.843

@xakepp35 I asked you what OS, cause the settings for windows 7, windows 8 and windows 10 are different. And let me rephrase the answer to a windows service. Having a UI does not let you start or terminate the service. The UI is an additional feature for better user experience. In any way the commands are these. – Jimmy_A – 2017-05-31T11:43:59.363

@xakepp35 You know what you are looking for in an answer, so you should edit your questions so everyone can understand what you are actually asking for. killing services by name, you usually kill parent services that in turn kill every child service as well. – Jimmy_A – 2017-05-31T11:51:08.447