Windows Tip Sheet

All-Knowing CMD Service Management

Not ready for PowerShell's Get-Service cmdlet? Get to know SC.exe, which can almost read your mind.

PowerShell has a handy cmdlet for managing services, but if you don't have it handy, you likely have its CMD.EXE predecessor, SC.EXE. You've likely read quite a bit about this utility, but you may not be familiar with some of its query abilities. In PowerShell, you can easily see all services or filter them to display only running or stopped. In the CMD shell, you can use an expression like this:

C:\sc query

You'll see a lot of information scroll by very quickly. You can pipe the expression to More, but you probably only need to see the service name anyway. Instead, use something like this:

C:\ sc query | find /i "name"

The expression shows you the service name and its display name for every running service. But what about stopped services? Use this:

C:\ sc query state= inactive | find /i "name"

There is an important space between the equal sign and "inactive." If you omit the space, SC will raise an error.

One advantage of SC.EXE over the Get-Service cmdlet is that it is very easy to query a remote machine:

C:\ sc \\server02 query | find /i "name"

This expression returns a list of all running services on Server02. If you prefer a simpler display, use this expression to get a more succinct result:

C:\ sc \\server02 query | find /i "display_name"

Of course if you use the inactive state parameter, you'll get a list of services not running on the remote server:

C:\ sc \\server02 query state= inactive | find /i "service_name"

Tech Help -- Just An
E-Mail Away

Got a Windows, Exchange or virtualization question or need troubleshooting help? Or maybe you want a better explanation than provided in the manuals? Describe your dilemma in an e-mail to the MCPmag.com editors at [email protected]; the best questions get answered in this column and garner the questioner with a nifty Redmond T-shirt.

When you send your questions, please include your full first and last name, location, certifications (if any) with your message. (If you prefer to remain anonymous, specify this in your message, but submit the requested information for verification purposes.)

The reason I filter for service name is that if I want to start a service, I need to use the service name and not its display name. Kind of like this:

C:\ sc \\server02 start "spooler"

Using SC's Query parameter will give you a great deal of information with a minimum of effort.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular