Solved

Using sc to list services and their startup type in order on Windows Server

Posted on 2010-11-10
5
821 Views
Last Modified: 2012-05-10
I'm looking to use sc to list all of the services (alphabetically) on a system and display their start-up type. Any ideas? I looked at the helped syntax but didn't know if it might require power shell?
0
Comment
Question by:adamshields
  • 3
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34108613
We should be able to do this with a BAT script, can you give a small sample of what you want the output to look like?

~bp
0
 
LVL 3

Author Comment

by:adamshields
ID: 34108694
I was hoping to be able to use a one liner to take care of it but that doesn't seem like it's going to happen that easily with powershell as I'm unable to get it to list the startup types.

Get-Service * |Sort Name

The code below is close but it needs to sort the services names alphabetically first.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Service",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "StartMode: " & objItem.StartMode
Next

Open in new window

0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 34108725
How about this?

wmic service get caption,startmode|sort

~bp
0
 
LVL 3

Author Closing Comment

by:adamshields
ID: 34108732
Thanks!
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34108751
Welcome, glad that was useful.

~bp
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question