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 


January 2007

SC's Dependency Problems

3 subcommands give you greater SC control
RSS
Subscribe to Windows IT Pro | See More Utilities Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Last month, in “Taking 3 Swings at SC” (InstantDoc ID 93849), I showed you how to use Windows Server 2003's SC (sc.exe) command to create a new service based on a fictional service application (i.e., C:\wc\wcmail.exe) that grabs pictures from a Web cam every few minutes. I walked you through the process of specifying a service account for the service, setting it to autostart, suppressing error messages, and giving it a display name of “Web cam image mailer.” As you'll recall, the command we ended up with was

sc create webimagemailer binpath= C:\wc\wcmail.exe
  start= auto displayname= “Web cam image mailer”
  obj= .\webcamguy password= swordfish error= ignore 

This month, let's go a little deeper. Suppose Webimagemailer can't run until the Windows Image Acquisition (WIA) service—with the key name stisvc—is running. In services terms, that would mean that Webimagemailer has stisvc as a dependency. To instruct Webimagemailer to wait until stisvc starts before starting itself, you would add the depend= stisvc parameter. (Don't forget: SC requires a space between the equals sign and the parameter value.) To specify that a service depends on more than one service, you would list the services' key names, separated by a forward slash. For example, to create the Webimagemailer service and specify that the stisvc and webclient services need to be running before it can start, you'd type

sc create webimagemailer binpath= C:\wc\wcmail.exe
  start= auto displayname= “Web cam image mailer”
  obj= .\webcamguy password= swordfish error= ignore depend= stisvc/webclient 

While we're on the topic of dependencies, you can use three SC subcommands—enumdepends, qc, and config—to query SC about them. To determine which services depend on a given service, you can type

sc enumdepend <servicekeyname>

Thus, to see which services depend on the Server service— which has the key name lanmanserver, you'd type

sc enumdepend lanmanserver 

Running that command on my test Windows 2003 server, for example, reveals that Netlogon, Dfs, and the computer browser services depend on the Server service.

To accomplish the reverse and determine Server dependencies, you can use the qc subcommand, as in

sc qc lanmanserver

This command dumps nine lines of information about the service, one of which is DEPENDENCIES. (SC tends to shout.) If you run that command, you'll find that Server doesn't depend on any services. To see a service that has more than one dependency, try the command on the Netlogon service. You'll see that Netlogon requires both the Server and Workstation services running before it can start.

Sometimes, dependencies are more complex than merely one service needing another. For example, some services will start only if one of three other services has started. (All three needn't be running; any one of the three will do.) You can instruct Windows about such a dynamic by informing the system that a given service depends on a group of services. Windows has a number of these services, such as the SCSI CDROM Class, SCSI miniport, Parallel arbitrator, NetBIOSGroup, NDIS, and Primary Disk services, to name a few. You can see all the services and drivers in a group by typing

sc query type= service|driver|all group= <”groupname”>

For example, to see all the services and drivers in the Primary Disk service group, you'd type

sc query type= all group= “primary disk”

Case doesn't seem to matter in group names. You can add a service to a given group, or create a new service group, by adding the group= groupname command to the SC Create command or by using SC Config to modify a service's group membership. For example, to add Webimagemailer to a new group named “unimportant,” you'd type

sc config webimagemailer group= unimportant  

As far as I can see, you can't put a service or driver in more than one service group.

You can also tell Windows that Webimagemailer shouldn't load without a particular group. To specify the fictional Webstartup group, you'd use the depends= webstartup parameter. To signal to Windows that Webstartup is a group—not another service—you'd prefix its name with a plus sign. For example, to reconfigure Webimagemailer to depend on the Webstartup startup group, you'd type

sc config webimagemailer depends= +webstartup 

Now you've seen how to use dependencies and groups to more specifically control a service's load order. You can understand why I was pleased to discover SC a few years ago.

End of Article



Reader Comments
Great stuff!

How would I amend the above service creation statement to show that the webimagemailer service is dependent on the webclient service locally, but also on the stisvc service which resides on \\someServer @ IP 1.2.3.4?

vicGar April 10, 2008 (Article Rating: )


From Mark Minasi:

I don’t think you can do that – I believe that dependencies must be within the same server’s services. (Neat idea, though!) Thanks for reading.

Jason Bovberg May 21, 2008 (Article Rating: )


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


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs 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