Tech Support > Microsoft Windows > DependOnService
DependOnService
Posted by Thomas M. on May 30th, 2008


XP SP2

I'm trying to create a little batch file that will list all the dependencies
for a given service. I found the following command on a Web site:

FOR /F "TOKENS=*" %s in ('DependOnService <Service Name>') do @echo %s

I have replaced the "<Service Name" wit "Spooler, but the command does not
work. Instead, it just tells me that DependOnService could not be found.

Can anyone tell me how to get this working in a simple batch file?

--Tom




Posted by VanguardLH on May 30th, 2008


"Thomas M." wrote in <news:OL8y$eewIHA.4376@TK2MSFTNGP06.phx.gbl>:

Where are you getting the string (in the parenthesis) that you are
searching through? Looks to me that you simply have a static string so
whatever you put there is all that can be parsed by the tokens
parameter.

Run "sc /?" from a DOS shell. You'll have to redirect the output to a
file and then read the file to search for the info. Make sure when
using the 'query' directive that you include the trailing space after
the equals sign.

Posted by Thomas M. on May 30th, 2008



"VanguardLH" <V@nguard.LH> wrote in message
news:O5KdnRaSP9vc-aLVnZ2dnUVZ_hudnZ2d@comcast.com...
First, thanks for the reply. Second, I think that I've solved the problem.
You can read through the background, or skip to the end if you just want to
see the solution that I found.


Background
-------------
I'm glad my post made some degree of sense because I was literally falling
asleep at the keyboard as I was writing it up. Although, I do notice a few
typos. Just to clarify, in the original command I have replaced "<Service
Name>" with "Spooler". I assume that you understood what I intended, but
just wanted to be clear.

I got the command from this site:

http://windowsitpro.com/article/arti...indows-xp.html

The way I read that page it seems like the command is intended to list out
all the services that are dependent on the service named in the command.
But like you, I wondered if the command simply searches the text that is
enclosed in quotes. It seems to me that the command is either not correct,
or that I have really mis-interpreted the information on the page.


Solution
--------
You asked where I got the service name of "Spooler" that I was using in the
command. I have a batch file that will list out all the service names with
the associated display names. I looked at that batch file (I didn't write
it) and found that it uses the sc command, which you also referenced. As
you suggested, I ran cmd and did sc /?, where I found the EnumDepend option.
So, running a command like:

sc enumdepend rpcss (RPCSS is the Remote Procedure Call service)

results in a list of all the services that depend on the RPC service. A
person could then redirect the output into a text file. This is really all
that I was looking for. I must have simply mis-understood the Web page
(link above) from which I got that original command.

Thanks for your help.

--Tom



Posted by Thomas M. on May 30th, 2008


Okay, now I have a different problem. I currently have the following batch
file.

set /p ServiceName=Enter the service name:
sc enumdepend %ServiceName% > ServiceDependencies.txt

There are a couple of other lines that get echoed to the screen to give the
user some instructions, but basically the two lines above are the whole
show. The first line prompts for the name of the service and the second
line takes that service name and outputs the results to a text file. If I
enter "spooler" as the service name all is well because there is only one
dependent service. However, if I enter "rpcss" which is the service name
for the Remote Procedure Call service and which has a ton of dependent
services, the resulting text file lists only 4 services and the last line of
the file is, "Enum: more data, need 5214 bytes."

I can stumble through the easy stuff, but I'm not a programmer. I'm
guessing that this is telling me that more memory needs to be allocated to
the output of the command, but I don't know that for certain and even if I'm
right I don't know how to fix it.

Can anyone tell me how to get around this problem so that the output file
will contain a complete listing of the dependent services?

--Tom



Posted by VanguardLH on May 31st, 2008


"Thomas M." wrote in <news:#WOwWrpwIHA.4476@TK2MSFTNGP06.phx.gbl>:

Run:

sc enumdepend

Notice what it says is its syntax. One of the parameters is a bufsize.
I don't know what the default is. It complained about needing another
5214 bytes. I didn't bother to count the bytes in what it did manage to
output. I just used a bufsize of 8192 and all of the output showed up
without the bufsize error.