Helps you diagnose any issues swiftly
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.
- To use the queryex command, run Command Prompt as an Administrator. You can find the app by searching cmd in the start menu.
- 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
- 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:”
- By default, the command lists all active processes. To look for inactive ones, modify the state parameter:
sc queryex type=service state=inactive
- 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.
- 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).
- 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.
- 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”
- 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
- 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.
- 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
- 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.
- 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
- Starting a service goes similarly:
Start-Service -Name Spooler
- If a service isn’t working correctly, you can also choose to restart it:
Restart-Service -Name Spooler
- 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.