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. ...

More fun TechEd 2005 Resources

Kevin points out some more TechEd resources ...

WinInfo Short Takes: Week of October 13, 2008

An often irreverent look at some of the week's other news... ...


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

Microsoft Exchange & Windows Connections event returns to Las Vegas Nov 10 - 13
Connections returns to Las Vegas for this exciting event where each attendee will receive SQL Server 2008 standard with 1 CAL. Co-located with Microsoft ASP.NET, SQL Server, and SharePoint Connections with over 250 in-depth sessions.

Free Online Event! Virtualization:Get the Facts!
Register now and attend this free, live in-depth online conference on November 13 and 20, 2008, produced by Windows IT Pro. All registrants are eligible to receive a complimentary one-year digital subscription to Windows IT Pro (a $49.95 value)!

Check Out Hyper-V Video on ITTV
Watch Karen Forster's interview on Hyper-V's performance on ITTV.net.

Ease Your Scripting Pains with the Flexibility of PowerShell!
Join MVP Paul Robichaux on December 11, 2008 at 11:00 AM EDT as he equips you with PowerShell basics in 3 introductory lessons, each followed by a live Q&A session—all on your own computer!

Latest Advancements in SSL Technology
There are a variety of different kinds of SSL to explore to ensure customer data is kept confidential and secure. In this paper, we will discuss some of these SSL advances to help you decide which would be best for your organization.

PASS Community Summit 2008 in Seattle on Nov 18-21
The don’t-miss event for Microsoft SQL Server Professionals. Register now and you’ll enjoy top-notch Microsoft and Community speakers and more.



Solving PST Management Problems
In this white paper, read about the top PST issues and how to administer local/network PST Files.

Get Protected -- Data Protection Manager 2007
Protect your virtualized environment with Data Protection Manager

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Maximize Your SharePoint Investment: Get Your Data Moving
Watch this web seminar now to learn how to maximize your SharePoint investment! Join us as we take a look at the complex business of securing, accessing and managing vast amounts of information in a global network and various ways to get your data moving.
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 Technology Resource 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