The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation


Using TASKLIST to check your Windows Services

If you are comfortable working with Windows Services from the command line, take a look at Microsoft’s TASKLIST utility. This often overlooked tool — available on all versions of Windows — can help you answer the following questions as you troubleshoot your Windows Services:

What is the PID Associated with a Running Service?

You can use the name of the service to look up the identifier of the process associated with it. For example, to find the PID of the Print Spooler service (named “Spooler”), use:

TASKLIST /SVC /FI "SERVICES eq Spooler"

Here is the result you can expect, with the PID listed in the central column:


TASKLIST - Find a Service's PID

What Windows Services are Being Hosted by a Specific Process?

If you are considering forcibly terminating a process, it may be wise to confirm that doing so will not unexpectedly kill related services! TASKLIST.EXE comes to the rescue by easily showing what services are running in a given process. For example, to see what services are behind the process with PID 1234, type:

TASKLIST /SVC /FI "PID eq 1234"

Here we can see that the svchost process with PID 1284 is managing five (!) core services:


TASKLIST - Find a PID's services

Note that TASKLIST can interrogate remote machines as well. Simply add the /S /U and /P flags to the command line to specify the system, user name and password respectively.

Enjoy!

Posted in Miscellaneous | Tagged | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *