Solved

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

Posted on 2010-11-10
5
810 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 51

Expert Comment

by:Bill Prew
Comment Utility
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
Comment Utility
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 51

Accepted Solution

by:
Bill Prew earned 500 total points
Comment Utility
How about this?

wmic service get caption,startmode|sort

~bp
0
 
LVL 3

Author Closing Comment

by:adamshields
Comment Utility
Thanks!
0
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
Welcome, glad that was useful.

~bp
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
OfficeMate Freezes on login or does not load after login credentials are input.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now