Меню Рубрики

Windows service stop service

Все о реестре Regedit / All about registry

Как остановить службу Windows ? / How stop windows service ?

Иногда возникает необходимость остановить службу в Windows , например, если возникает подозрение, что приложение не работает из-за работы какой-либо службы.

Сегодня мы рассмотрим пример остановки службы через командную строку.

Для начала, необходимо определиться какую службу мы будет останавливать.

Нажмите Пуск, далее правой кнопкой мыши нажмите по значку Компьютер и выберите пункт Управление.

Если у вас Windows 10, то достаточно нажать правой кнопкой мышки на кнопку Пуск и выбрать пункт Управление компьютером

В окне управления компьютером выбираем Службы и ищем службу интересующую нас службу.

Рассмотрим пример отключения службы Защитник Windows . Не рекомендую отключать данную службу, если у Вас отсутствует Антивирус. Щелкните два раза на службу.

В окне описания службы мы отображено консольное название службы, а именно Windefend

Запустите командную строку сочетанием клавиш Win + R , а в окне Выполнить наберите cmd

В командной строке напишите:

net stop WinDefend


После данных действий служба должна остановиться.

Остановить службу можно и другой командой, а именно командой sc


В описании данной команды есть очень много возможностей.

Командой sc можно запускать, останавливать или запрашивать состояние служб на локальном и удаленном компьютере.

Рассмотрим пример запроса Имени службы через команду sc

На картинке показан запрос имени службы.

Командой sc query | more — мы можем отобразить список Служб на компьютере построчно.

Остановить службу на локальном компьютере можно командой:

sc stop Имя службы

При о запуске, остановке или просмотре состояния службы на удаленном компьютере можно воспользоваться командой sc.

Если вы создаете cmd файл только для локального компьютера, вполне сойдет и net .

Sometimes you need to stop a service in Windows, for example, if you suspect that an application is not running because of a service.

Today we will look at an example of stopping a service via the command line.

For a start, it is necessary to decide what service we will stop.

If you Operation system Windows 7:

Click Start button, right-click Computer, and then click Computer Management

If you have Windows 10, just right — click on the Start button and select Computer Management

In the computer control window, select the Service and look for the service we are interested in.

Consider an example of disabling the Windows Defender service. I do not recommend stop this service if you do not have an antivirus. Double-click the service.

In the service description window, we display the console name of the service, namely Windefend.

Run command prompt (Win+R buttons) in the Run window, type cmd

At the command line, type:

net stop WinDefend

After these actions, the service should stop.

You can also stop the service with another command, namely sc


There are many possibilities in the description of this command.

You can use the sc command to stop services on a remote computer or to query the status of services on a remote computer.

Command sc query |more — we can display the list of Services on the computer line by line.

You can stop the service on the local computer by using the following command

sc stop service Name you service


When you start, stop or view the status of a service on a remote computer, you can use the sc command.

If you are creating a cmd file for your local you can use the net command.

Источник

Быстрая остановка службы через NET STOP

В командной оболочке команда NET STOP используется для остановки системных служб операционной системы Windows. Быстрая остановка службы через командную строку позволит системным администраторам сэкономить значительное количество времени по сравнению с графическими эквивалентами. Также возможно применение NET STOP в командных сценариях для автоматизации процессов.

Параметры NET STOP

Команда NET STOP останавливает одну из служб Windows. Синтаксис следующий — NET STOP [служба], где [служба] — может быть одной из следующих служб:

  • BROWSER — Обозреватель компьютеров;
  • DHCP — DHCP-клиент;
  • EVENTLOG — Журнал событий;
  • MESSENGER — Служба сообщений;
  • NETLOGON — Сетевой вход в систему;
  • NTLMSSP — Поставщик поддержки безопасности NT LM;
  • RASMAN — Диспетчер подключений удаленного доступа;
  • REMOTEACCESS — Маршрутизация и удаленный доступ;
  • RPCLOCATOR — Локатор удаленного вызова процедур (RPC);
  • RPCSS — Удаленный вызов процедур (RPC);
  • SCHEDULE — Планировщик заданий;
  • SERVER — Сервер;
  • SPOOLER — Диспетчер очереди печати;
  • LMHOSTS — Поддержка NetBIOS через TCP/IP;
  • UPS — Источник бесперебойного питания;
  • WORKSTATION — Рабочая станция.

Остановка одной из служб системы Windows может привести к отключению сетевых соединений используемых этой службой. Kроме того, некоторые службы зависят от других служб. Kоманда NET STOP может также использоваться для остановки служб не входящих в состав Windows.

Синтаксис команды довольно простой, нужно лишь ознакомиться с ее параметрами и запомнить имена некоторых служб.

Примеры команды NET STOP

Остановить работу службы «Сервер» можно с помощью следующей команды:

Остановить работу службы «Диспетчер печати» можно командой

Примеры остановки наиболее популярных служб

  • net stop dhcp – остановка DHCP- клиента Windows (служба клиента автоматического получения IP-адресов в сети)
  • net stop Dnscache — остановка службы DNS-клиента операционной системы
  • net stop SharedAccess – остановка брандмауэра Windows(Общий доступ к Интернету ICS)
  • net stop Eventlog — остановка службы журнала событий
  • net stop Schedule — — остановка службы планировщика заданий Task Scheduler
  • net stop MSIServer — остановка службы Windows Installer

С полным списком служб операционной системы Windows и их сокращенными названиями можно ознакомиться в статье – «Перечень служб Windows — полная информация». Net Stop используется вкупе с другими командами net, такими как:

  • NET START – запуск службы;
  • NET PAUSE – приостановка службы;
  • NET CONTINUE – возобновление работы службы.

Видео — Управление службами Windows через командную строку

Источник

StopService method of the Win32_Service class

The StopService WMI class method places the service, represented by the Win32_Service object, in the stopped state.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax

Parameters

This method has no parameters.

Return value

Returns one of the values listed in the following list, or any other value to indicate an error. For additional error codes, see WMI Error Constants or WbemErrorEnum. For general HRESULT values, see System Error Codes.

The request was accepted.

The request is not supported.

The user did not have the necessary access.

The service cannot be stopped because other services that are running are dependent on it.

The requested control code is not valid, or it is unacceptable to the service.

The requested control code cannot be sent to the service because the state of the service (Win32_BaseService.State property) is equal to 0, 1, or 2.

The service has not been started.

The service did not respond to the start request in a timely fashion.

Unknown failure when starting the service.

The directory path to the service executable file was not found.

The service is already running.

The database to add a new service is locked.

A dependency this service relies on has been removed from the system.

The service failed to find the service needed from a dependent service.

The service has been disabled from the system.

The service does not have the correct authentication to run on the system.

This service is being removed from the system.

The service has no execution thread.

The service has circular dependencies when it starts.

A service is running under the same name.

The service name has invalid characters.

Invalid parameters have been passed to the service.

The account under which this service runs is either invalid or lacks the permissions to run the service.

The service exists in the database of services available from the system.

The service is currently paused in the system.

Remarks

After you have determined which services can be stopped or paused, you can use the StopService and PauseService methods to stop and pause services. The decision to stop a service rather than pause it, or vice versa, depends on several factors, including the following:

  • Is the service capable of being paused? If not, your only option is the stop the service.
  • Do you need to continue handling client requests for anyone already connected to the service? If so, pausing a service typically allows it to handle existing clients while denying access to new clients. By contrast, when you stop a service, all clients are immediately disconnected.
  • Do you need to reconfigure a service and have the changes take effect immediately? Although service properties can be changed while a service is paused, most of them do not take effect until the service is actually stopped and restarted.

The scripting code required to stop a service is almost identical to the code required to pause the service.

If you attempt to stop a service which has dependent services running, the StopService method fails with a return value of 3. The dependent services must be stopped first.

If you stop a service, then immediately check the Win32_Service.State property, as the value may still show the service as running.

Examples

The Set-RemoteService PowerShell sample Sets service state for remote machines.

The Stop a Service and Its Dependents VBScript sample stops a service and all dependent services.

The following VBScript code sample demonstrates how to shut down a service.

The following Perl code sample demonstrates how to shut down a service.

The following VBScript code example shows that you cannot stop the NetDDE service until the dependent services have been stopped. To run the script, ensure that the NetDDE service and its dependent services are running by using the Services.msc MMC snap-in or the Net Start command.

The Win32_DependentService class allows you to locate service dependencies through an Associators Of query.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Windows service start failure что это
  • Windows service ssh client
  • Windows service run as
  • Windows service restart cmd
  • Windows service remove service