Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


February 2007

Unleashing SC on Service Configuration

One more look at this tool reveals its true power
RSS
Subscribe to Windows IT Pro | See More Resource Kit Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Ready to finish our look at SC (sc.exe), the command-line tool that offers wide-reaching control over services? In previous columns, I've demonstrated how SC lets you start and stop services, create new ones, delete existing ones, and control dependencies between services. But that's not all you can do with services. For example, I often find myself changing a service's startup status—whether it starts automatically or manually, whether it's disabled, and so on. You can control startup status, and much more, by using the SC Config command.

How It Works
The SC Config command largely mirrors the SC Create command, which I've covered before. Its overall syntax looks like

sc config <servicekeyname> <option= value>   
<option= value>

Here's an example that will illustrate this command's usefulness: Ever since Windows Server 2003 Service Pack 1 (SP1) and Windows XP SP2 disabled the Messenger service, I've gotten pretty regular email from people who say they need it. (Some folks really like the Net Send command.) To configure the Messenger service to automatically start every time you boot your computer, you could type

sc config messenger option= auto 

(Recall that SC has the syntactic quirk of requiring a space between the equals sign and the option's value.) The other possible values are boot, system, demand (i.e., manual), and disabled.

By the way, Windows Vista systems have yet another possible value—delayed-auto—that reflects Vista's new delayed start option. The notion of delayed-start services reflects Microsoft's observation that many auto-start services need to start automatically but don't necessarily have to start immediately. Microsoft wanted Vista to get started up and ready to go as quickly as possible, and part of the reason why the XP and Windows 2000 desktop OSs boot slowly is because they're waiting for those auto-start services that always start immediately.

Other useful options for the SC Config command are password, error, depend, and perhaps obj. You're already familiar with the obj and password options. A couple months ago, I showed you how to use them for creating a new service: obj= lets you configure which account to run a service under with SC Config just as the obj= parameter lets you specify the service account in SC Create. You probably won't change service accounts very often, but you might end up changing those accounts' passwords, and for that task, you can use the password= option. If a service with a key name of myservice has a service account whose password has changed to swordfish, you can inform Windows as follows:

sc config myservice password= swordfish 

You can use the error= option to control Windows' behavior when a service fails. Remember, while creating a new Windows service, you can tell Windows to respond to a service failure in one of four ways: ignore, which merely notes the failure in the event log; normal, which acknowledges the failure with a message but lets operations continue; severe, which reboots the system with Last Known Good and tries again; or critical, which reboots the system, retries the service, and—if it still fails to run—bluescreens the system. I can tell Windows that if myservice doesn't run, Windows doesn't run (clearly a measure to use sparingly), as follows:

sc config myservice error= critical 

We're not quite done with SC Config—there's one more oddity to look at. Over the course of the past three columns, I've shown you that whenever SC lets you specify more than one option/value pair for a command, you separate those option/value pairs with forward slashes. I demonstrated the technique last month with the depend= option, and you can also observe it if you look up the syntax of Vista's SC command. By contrast, with SC Config, you specify more than one option by merely separating them with spaces. (Granted, this behavior might be considered standard in the scripting world; it just seems odd in the context of SC's other syntax.) For example, to combine those last two commands into one, I could type

sc config myservice password= swordfish error= critical

Consider the Possibilities
Need to control a service from the command line because you want to use a batch file? Want to use a low-bandwidth textual interface for remotely configuring a system? Perhaps you're just getting up to speed with the command line so that you can control the upcoming command-line-only Server Core product. Whatever your scenario, you'll find SC a useful tool.

End of Article



Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

Escape From Yesterworld

Kevin points you to the funniest SQL Server website ever! ...

The Desktop tab is missing from the Display Properties in Windows XP?

...


Related Articles Castaway on Command-Prompt Island

Task Automation Whitepapers Essential Guide to E-discovery and Recovery for Microsoft Exchange

Continuous Data Protection and Recovery for Microsoft Exchange

Protecting (You and) Your Data with Exchange Server 2007

Related Events Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

WinConnections Conference Fall 2008
Don’t miss the premier event for Microsoft IT Professionals in Las Vegas, November 10-13. Register and book your room by August 25 and receive a FREE room night (based on a three night minimum stay).

Maximize your SharePoint Investment – 8 Cities
Discover best practices and tips for both architecting and administering SharePoint. Early Bird Price of $99 through Sept 15th.

Find a new job now on the all new IT Job Hound!
Search jobs, post your resume, and set up job e-mail alerts!

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Top Tools for Virtualization Disaster Recovery & Replication
View this web seminar on August 14th to learn about two tools that will result in faster backup and restore with P2V disaster recovery.

SharePointConnections Conference Fall 2008
Don’t miss the premier event for Microsoft IT Professionals in Las Vegas, November 10-13. Register and book your room by August 25 and receive a FREE room night (based on a three night minimum stay).

VMworld 2008 - Sign Up Today!
Join your peers on September 15-18 at The Venetian Hotel in Las Vegas as VMware hosts VMworld 2008, the leading Virtualization event.



When managing just VMware isn’t enough
Plan/Manage/Secure – NetIQ VMware management. Download whitepaper.

What’s up with your network? Find out with ipMonitor
Availability monitoring for servers, applications and networks – FREE trial

Microsoft® Tech•Ed EMEA 2008 IT Professionals
Advance your thinking with new ideas and practical real-world solutions at Microsoft’s FIVE day technical infrastructure conference 3-7 Nov., 2008. Register before 26 September 2008 to save €300.

Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.

Are You Really Compliant with Software Regulations?
View this web seminar that will help you with compliance best practices and check out a management solution to assure that you won’t be in jeopardy of an audit.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16 in London.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing