Windows вывести список служб

The services in Windows can be listed using the Service Manager tool.

To start the Service Manager GUI, press ⊞ Win keybutton to open the “Start” menu, type in services to search for the Service Manager and press Enter to launch it.

The services can also be listed using the command-line prompt (CMD) or the PowerShell.

In this note i am showing how to list the services and how to search for a specific service in Windows using the command-line prompt (CMD) or the PowerShell.

Cool Tip: List processes in Windows from the CMD! Read more →

List Services Using Command Line (CMD)

List all services:

C:\> sc queryex type=service state=all

List service names only:

C:\> sc queryex type=service state=all | find /i "SERVICE_NAME:"

Search for specific service:

C:\> sc queryex type=service state=all | find /i "SERVICE_NAME: myService"

Get the status of a specific service:

C:\> sc query myService

Get a list of the running services:

C:\> sc queryex type=service
- or -
C:\> sc queryex type=service state=active
-or -
C:\> net start

Get a list of the stopped services:

C:\> sc queryex type=service state=inactive

Cool Tip: Start/Stop a service in Windows from the CMD & PowerShell! Read more →

List all services:

PS C:\> Get-Service

Search for specific service:

PS C:\> Get-Service | Where-Object {$_.Name -like "*myService*"}

Get the status of a specific service:

PS C:\> Get-Service myService

Get a list of the running services:

PS C:\> Get-Service | Where-Object {$_.Status -eq "Running"}

Get a list of the stopped services:

PS C:\> Get-Service | Where-Object {$_.Status -eq "Stopped"}

Was it useful? Share this post with the world!

How to block File Sharing for one or more IP Addresses in Windows

As you most likely already know, in Windows operating systems, a Windows service is a computer program that operates in the background, just like daemons in a Unix-like environment. They can be configured to either start when the operating system is started and run in the background as long as Windows is running, or started manually using the Service Manager tool, which can be launched by typing
services.msc  from the command prompt or by opening the start menu, typing «services» from the Start Menu and then launching the Service Manager icon that should show up right away.

In this post we’ll see some useful command-line prompt (CMD) and Powershell commands that can be used from most Windows environments (including Windows 10 and Windows Server) to list the installed / active / inactive services, as well as search for a specific service in Windows.

If you’re looking for a complete list of all the existing/available Windows Services, check out this post.

Command-Line (CMD) commands

How to list all Windows services:

sc queryex type=service state=all

How to list all Windows services (names only):

sc queryex type=service state=all | find /i «SERVICE_NAME:»

How to list all the running Windows services, excluding the stopped / inactive ones:

sc queryex type=service state=active

How to list all the stopped / inactive Windows services, excluding the running ones:

sc queryex type=service state=inactive

How to search for a given Windows service (by name):

sc queryex type=service state=all | find /i «SERVICE_NAME: MyServiceName»

How to retrieve the status of a given service (by name):

PowerShell commands

How to list all Windows services:

How to list all Windows services (names only):

sc queryex type=service state=all | find /i «SERVICE_NAME:»

How to list all the running Windows services, excluding the stopped / inactive ones:

Get-Service | WhereObject {$_.Status -eq «Running»}

How to list all the stopped / inactive Windows services, excluding the running ones:

Get-Service | WhereObject {$_.Status -eq «Stopped»}

How to search for a specific Windows service:

Get-Service | WhereObject {$_.Name -like «*MyServiceName*»}

How to retrieve the status of a given service (by name):

Get-Service MyServiceName*

Conclusions

We definitely hope that this post will help those system administrators that are looking for a quick and effective way to list, filter, search and/or retrieve the status of the Windows Services installed on their Windows machines using the command-line prompt (CMD) or Powershell.

The running applications you see on your screen are a fraction of what is happening in Windows. From managing device drivers to ensuring security, a bunch of background processes maintain a functioning Windows PC.

For any system administrator overseeing multiple computers, it is important to be able to view the status of these critical services. The Task Manager approach is too slow for this, and you cannot automate it with a script.

The solution? Command-line tools. Using the Command Prompt or PowerShell, you can quickly get a read on the operational Microsoft services running on a system, helping you diagnose any issues swiftly. 

Listing Windows Services In the Command Prompt

While not as flexible or powerful as Windows PowerShell, the Command Prompt is still an excellent tool for system administrators. You can use the queryex command to get the status of both active and disabled services and then use the taskkill command to end pesky processes.

  1. To use the queryex command, run Command Prompt as an Administrator. You can find the app by searching cmd in the start menu.

  1. There are many ways of using the sc queryex command. Type and State are the two most commonly used parameters. For example, enter the following command to view all  Windows processes:

sc queryex type=service state=all

  1. The default view can be a bit overwhelming. You can display just the names of processes to make the list easier to parse:

sc queryex type=service state=all | find /i “SERVICE_NAME:”

  1. By default, the command lists all active processes. To look for inactive ones, modify the state parameter:

sc queryex type=service state=inactive

  1. You can also query the status of a specific process by its name. This is incredibly useful for system administrators, as they can set up batch files to check many processes at once. Here’s an example:

sc query DeviceInstall

Listing Windows Services in PowerShell

PowerShell is meant to be a dedicated command-line shell for modern Windows. As such, it provides access to pretty much every operating system component through commands, and Windows services are no exception.

PowerShell’s advantage is that you can automate it easily. All PowerShell commands can be compiled into complex scripts, allowing you to set up system administration tasks on multiple PCs without hassle.

  1. Start by opening PowerShell. You can search for it in the Start Menu; just make sure to run an elevated instance (i.e., as an Administrator).

  1. The simplest command for listing Windows services on PowerShell is Get-Service. It shows all services on your computer, along with their status and names. The only problem is that the list of services can be pretty long.

  1. When using Get-Service, it is a better idea to export the list to a text file. You can do this using pipes, like this:

Get-Service | Out-File “C:\logs\All_Services.txt”

  1. To look up the status of a specific service, follow the Get-Service command with the name of the service. You can request the status of multiple processes by separating their names with commas.

Get-Service CryptSvc, COMSysApp

  1. Pipes can also be used to combine the Get-Service cmdlet with the Where-Object function and filter the results by Status. The following command illustrates this by getting all Running services:

Get-Service | Where-Object {$_.Status -EQ “Running”}

Checking Service Dependencies

Any complex process is split into multiple interdependent services. This is why simply getting the status of a particular service is often not enough. You also need to check the status of the services that service is dependent on.

  1. To view the services required by a particular service, use the -RequiredServices flag with the Get-Service cmdlet. Here’s an example:

Get-Service -Name CryptSvc –RequiredServices

  1. Similarly, to get a list of services that depend on a specific service, take advantage of the -DependentServices flag.

Get-Service -Name CryptSvc -DependentServices

These two flags are crucial in writing scripts to automatically start or stop Windows services, as they give you a way to keep track of all the services connected with the affected service.

Listing Windows Services On Remote Computers

The PowerShell method is not limited to local computers. You can use the Get-Service cmdlet with the same syntax described above to query the processes of remote PCs as well. Just append the -ComputerName flag at the end to specify which remote computer to retrieve information from. 

Here’s an example:

get-service CryptSvc -ComputerName Workstation7

Managing Windows Services in PowerShell

Getting the status of services isn’t the only thing you can do in Windows PowerShell. As a full-fledged scripting environment, it provides script alternatives to all GUI options. 

Powershell cmdlets can stop, start, restart, or even modify services. Paired with automated Get-Service commands, PowerShell scripts can be written to fully automate everyday system management tasks.

  1. In addition to querying the status of services, you can also use PowerShell to manage them. Starting or stopping services can be done with a single command, requiring only the name of the service. For example, this is how you can stop a service:

Stop-Service -Name Spooler

  1. Starting a service goes similarly:

Start-Service -Name Spooler

  1. If a service isn’t working correctly, you can also choose to restart it:

Restart-Service -Name Spooler

  1. There is also the Set-Service cmdlet that can be used to change the properties of a service. Here we disable the automatic startup of the Print Spooler service:

Set-Service ‘Spooler’ -StartupType Disabled

What Is the Best Way to List Windows Services?

Whether you are running Windows 10 or a Windows Server, being able to view a list of all Windows services can be handy. You can diagnose issues with critical system functions or stop unnecessary Microsoft services to improve performance.

For this purpose, PowerShell is the best option. While you can obtain a service list in Command Prompt, the additional functionality provided by PowerShell is more useful.

You can use PowerShell cmdlets to get the service status of Windows processes, filtering them by their status or other parameters. It is also easy to determine dependent services and start or stop them as required.

Related Posts

  • How to Fix a “This file does not have an app associated with it” Error on Windows
  • How to Add OneDrive to Windows File Explorer
  • How to Fix an Update Error 0x800705b4 on Windows
  • How to Resolve “A JavaScript error occured in the main process” Error on Windows
  • How to Fix the Network Discovery Is Turned Off Error on Windows

Команда для получения списка сервисов (служб) простая:

net start

net start

В powershell тоже работает.

powershell

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

Похожие материалы

Почитать

Windows Service management through the command line is really a good approach when you want to manage plenty of services and perform day to day actions like stop, start and restart

I think you would agree, If I say GUI is fun for entry-level but when it comes to performing the job smartly and creating automation for efficiency. Command-line is your key

PowerShell has a lot of commands to help us manage the windows server better and create automation and do the boring (or) repetitive tasks swiftly

In this article, we are going to see How to Manage Services from the Windows Command line using PowerShell. We are going to see various examples of  How to List , Stop, Start, Restart a Single Service or multiple Services.

To Manage the Services in Windows, We have a pack of Powershell commands and each does a unique job in the Windows Service Management. It helps us perform our day to day needs like Stopping, Starting, Restarting, Listing, Searching, etc

In this article, we are going to see various Windows Powershell commands  such as

  • Get-Sevice
  • Stop-Service
  • Start-Service
  • Where-Object
  • Restart-Service

Not just this, There are few more and look at the index to know what this article is packaged with

I am thrilled and I hope you are too. Let’s march on.

Index

  1. How to List the Services  Windows Command Line
  2. How to List only Running or Stopped  Services in PowerShell
  3. How to List a Service or Get Service by Name in Windows
  4. How to Search for the Service[s] by Status, DisplayName, Search String etc.
  5. How to Stop the Service[s] in Windows Command Line
  6. How to Start the Service[s] in Windows Command Line
  7. How to Restart the Service[s] in Windows Command Line

How to List the Services in Windows Command Line

To List, all the Services in your Windows PC or Server, Perform the Following Steps

  1. Open PowerShell Terminal or PowerShell ISE as Administrator
  2. Type Get-Service in the Terminal

You would be presented with all the available Services on the Windows Machine

The result would container three columns as shown below, Status, Name, and DisplayName

You can search or List a Single or Multiple Services based on any of these columns, which we will see in upcoming sections on this article.

PS C:\Users\sarav>

GetService

Status   Name               DisplayName                           
------   ----               -----------                           
Stopped  AarSvc_ba23f       Agent Activation Runtime_ba23f        
Stopped  AJRouter           AllJoyn Router Service                
Stopped  ALG                Application Layer Gateway Service     
Stopped  AppIDSvc           Application Identity                  
Running  Appinfo            Application Information               
Stopped  AppReadiness       App Readiness                         
Running  AppXSvc            AppX Deployment Service (AppXSVC)     
Running  AudioEndpointBu... Windows Audio Endpoint Builder        
Running  Audiosrv           Windows Audio                         
Stopped  autotimesvc        Cellular Time                         
Stopped  AxInstSV           ActiveX Installer (AxInstSV)          
Stopped  BcastDVRUserSer... GameDVR and Broadcast User Service_...
Stopped  BDESVC             BitLocker Drive Encryption Service    

How to List only Running or Stopped  Services in PowerShell

In this section we are going to see how to list the windows services based on a Specific State they are in.

To List, Either only Running and Stopped Services, PowerShell Get-Service Command can be used along with one more Filtering command named Where-Object .

It acts like a grep of Linux and it does the job so perfect and precise

So to List Running or Stopped Services in Windows Command line you should do the following

  1. Open PowerShell Terminal or PowerShell ISE as Administrator
  2. Use one of the following command based on your requirement

To List Only The Running Services

Get-Service | Where-Object {$_.Status -eq "Running" }

To List only the Stopped Services

Get-Service | Where-Object {$_.Status -eq "Stopped" }

In fact,  You can Use any of the Following State Value in place of Running or Stopped to get the Services in that State.

Value Meaning
ContinuePending The service has been paused and is about to continue.
Paused The service is paused.
PausePending The service is in the process of pausing.
Running The service is running.
StartPending The service is in the process of starting.
Stopped The service is not running.
StopPending The service is in the process of stopping.

For example, If you would like to Get a Service which is in Paused State  then your command should be like this

Get-Service | Where-Object {$_.Status -eq "Paused" }

How to List a Service or Get Service by Name in Windows

To List or to Get a Service by Name you have to be aware of the Name of the Service or at least a part of the Service name as we can use * wildcard to find the rest.

To List or to Get Service by Name do the following

  1. Open PowerShell Terminal or PowerShell ISE as Administrator
  2. Use the following Get-Service the command along with a -Name (or) -DisplayName parameter

To List a Service named Jenkins I can use any of the following commands and Be informed that Service Name is Case Insensitive

Get-Service -Name jenkins

(or)

Get-Service -Name jenkins

(or)

Get-Service -DisplayName jenkins

(or)

Get-Service -Name JEnKins

(or)

Get-Service -DisplayName JEnKins

(or)

Get-Service -Name  jen*s

How to Search for the Service[s] by More Filters

Sometimes, Our requirement would not be simpler as we think, It might get complicated when we get a requirement like

We might have to list (or) restart all the tomcat instances running on the server and exclude instance which contains a Specific String in its name

Let’s Suppose, that we have a Windows Server with N number of Tomcat Services (instances) and they are named after their Environment name they belong to like dev, uat etc. like Dev_Tomcat1, Test_Tomcat2, Uat_Tomcat4 and so on.

Now to list only the DEV and UAT instances and not SIT we would have to use some more filters other than just Name or DisplayName

Here are some examples related to this type of scenario.

# All these examples made based on the presence of 
# Environment Names `SIT` `UAT` `Dev` in the Service Name of
# Service Display Name

# The Search is By Default CASE INSENSITIVE


# Find Tomcat Instances belong to Test Environment

Get-Service -DisplayName "*Tomcat*" -Include "*Test*"

(or)

Get-Service -DisplayName "*Tomcat*" -Include "*tEst*"

----


# Find All Tomcat Instances EXCEPT the ones belong TEST Environment

Get-Service -DisplayName "*Tomcat*" -Exclude "*Test*"


---- 


# You can also add STATUS Filter into this command

Get-Service -DisplayName "*Tomcat*" -Exclude "*Test*"|Where-Object {$_.Status -eq "Running"}

We have so far seen, how to list the services in windows machine (PC or Server) using the Powershell command line.

Now we are going to see, How to Stop the Service[s] in Windows PowerShell Command Line

Now let us Split this Part into two as follows

  • How to Stop a Single Service by Name
  • How to Stop One or More Services matching the Query (or) Search term

Despite you are stopping a Single Service or Multiple Services. You have to first list the Services with Get-Service with necessary Filters like -Name or Status etc.

Once the result is presented, With the help of pipe | symbol you pass all the services to an another Command called Stop-Service

Stop-Service command is responsible to stop the service (or) Services

Simply put, to Stop the Service or Services. You just need to list it first and make sure thats what you want to be stopped and then redirect it to Stop-Service with the help of pipe

Here are some of Windows Stop Service Example commands

# Simply Stop the Service named Jenkins

Get-Service -Name Jenkins|Stop-Service

---

# Stop all Running Services 

Get-Service|Where-Object {$_.Status -eq "Running"}|Stop-Service 

---

# List and Stop All Running *Tomcat* Services

 Get-Service -DisplayName "*Tomcat*"|Where-Object {$_.Status -eq "Running"}|Stop-Service 

---

# List and Stop All Running Tomcat Services, 
# Only Production, No DEV, UAT, SIT ( We Presume Display Name Contains the Environment Name)


 Get-Service -DisplayName "*Tomcat*" -Exclude "*DEV*"  "*SIT*"  "*UAT*"|Where-Object {$_.Status -eq "Running"}|Stop-Service 

How to Start the Service[s] in Windows Command Line

Now we are going to see, How to Start the Service[s] in Windows PowerShell Command Line

Despite you are Starting a Single Service or Multiple Services. You have to first list the Services with Get-Service with necessary Filters like -Name or Status etc.

Once the result is presented, With the help of pipe | symbol you pass all the services to another Command called Start-Service

Here are some of Windows Start Service from Command Line examples

# Simply Stop the Service named Jenkins

Get-Servicec -Name Jenkins|

Start-Service

---

# Stop all Running Services 

Get-Service|Where-Object {$_.Status -eq "Running"}|

Start-Service

 

---

# List and Stop All Running *Tomcat* Services

 Get-Service -DisplayName "*Tomcat*"|Where-Object {$_.Status -eq "Running"}|

Start-Service

 

---

# List and Stop All Running Tomcat Services, 
# Only Production, No DEV, UAT, SIT ( We Presume Display Name Contains the Environment Name)


 Get-Service -DisplayName "*Tomcat*" -Exclude "*DEV*"  "*SIT*"  "*UAT*"|Where-Object {$_.Status -eq "Running"}|

Start-Service

 

How to Restart the Service[s] in Windows Command Line

We have just learned how to Stop and Start the services, Now it is a time to learn How to Restart Service from Windows Command Line

To Restart windows Service Command Line do the following

  1. Open PowerShell Terminal or PowerShell ISE as Administrator
  2. Use the following Get-Service the command along with a -Name (or) -DisplayName parameter and List the Services you want to be restarted
  3. In the same Command add a pipe | symbol at the suffix along with a command Restart-Service

To Restart Windows Service from Command Line, First we need to list the services that we want to be restarted using Get-Service we can customize and Search for  the Services you want using Get-Service parameters like Name and DisplayName , Status etc

Once we have the list ready with Single or Multiple Services that we want to restart.

We can use another command, Given dedicatedly to restart services named Restart-Service

In most cases, we would like to have more control on the Restart process, in such cases, you can try to Stop and Start the services using Stop-Service and Start-Service commands rather directly using Restart-Service

Here are few examples of How to restart the Service in Windows Command Line

# Simply Stop the Service named Jenkins

Get-Servicec -Name Jenkins|

Restart-Service

---

# Stop all Running Services 

Get-Service|Where-Object {$_.Status -eq "Running"}|

Restart-Service

 

---

# List and Stop All Running *Tomcat* Services

 Get-Service -DisplayName "*Tomcat*"|Where-Object {$_.Status -eq "Running"}|

Restart-Service

 

---

# List and Stop All Running Tomcat Services, 
# Only Production, No DEV, UAT, SIT ( We Presume Display Name Contains the Environment Name)


 Get-Service -DisplayName "*Tomcat*" -Exclude "*DEV*"  "*SIT*"  "*UAT*"|Where-Object {$_.Status -eq "Running"}|

Restart-Service

 

So This is how Windows PowerShell commands help us to manage the Windows services from Command line, We learned how to List, stop, start and restart windows services from command line

With this command line, We can stop, start, restart  Multiple services at once in bulk that’s what I like the most about it.

If you have any questions for me. Please feel free to comment

Rate this article [ratings] Share it with your friends if you find it worth

Cheers
Rumen Lishkov

Follow us onFacebook orTwitter

For more practical videos and tutorials. Subscribe to our channel

Find me on Linkedin My Profile

For any Consultation or to hire us [email protected]

If you like this article. Show your Support! Buy me a Coffee.

Signup for Exclusive «Subscriber-only» Content



Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Программа для редактирования образа windows 10
  • Служба печати windows 10 как называется
  • Как поставить обои на рабочий стол windows 7 начальная
  • Какие настройки нужно отключить в windows 10
  • Ssd mini tweaker настройка windows 7