Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List what computers a given service is running on 1

Status
Not open for further replies.
If you figure out how to do this - definitely let me know or post your code! :) I know of no way to do this short of some seriously tedious batchwork and about 500 lines of code, or 3rd party software..but yours looks simple.
I'm gonna say it's impossible with SC.exe, but i'd LOVE to be wrong on this one!!! :p pbxman
Systems Administrator

Please let Tek-Tips members know their posts were helpful.
 
what do you mean if i figure it out?

i was using that batch line to list which computers had messenger running on when i was trying to figure out how to disable it. ===============
Security Forums
 
ehh..was this a "tip" and not a question? :) I totally misread that post if thats the case. hahaha

So I tried this, and im getting "query was unexpected at this time". Is this a copy/paste of the code, and it should work? I replaced "servicename" above with the service im querying, and it fails with the above error. This would be a great tool to have! pbxman
Systems Administrator

Please let Tek-Tips members know their posts were helpful.
 
no it wasnt a paste. i had my dos window open next to opera and copied what it said
better to not do the echo off until u have it right that way it'll show what it's doing

if u put it in a .bat file u have to do %%a instead of %a

i used the tip lightbulb icon :)

if u just do c:\>net view | find "\\" /I you should get a list of computers on the network

the for loop takes each line of the result of net view etc, equates it to %a and then
replaces %a in sc %a query servicename

the | find "running" checks each line of the output of the sc cmd and outputs the lines with "running" on. by itself this isnt useful so echo %a prints the computername on the next line so you can see which computer it is. the && means only do it if the last command was successful.

ok?

===============
Security Forums
 
That is an awesome tool! I've been looking for something like that for a long time, but never sat down and wrote it. I didn't think it would be that easy! Im glad i was wrong. Good work, browolf..That makes things a lot easier in the sysadmin dept. :) pbxman
Systems Administrator

Please let Tek-Tips members know their posts were helpful.
 
it's taken me a long time to get to the hang of "for /f" loops and "| find". i usually use them for

for /f %a in ('dir *. /b') copy file.doc %a
ie copy a file into ppls userareas

i also use it with ls tool's down program to shut off computers with certain names remotely (our comps are like in rooms so t12-x)
ls tools >>
i.e. go.bat
@echo off
net view | find "%1" >> %1.$$$
for /F %%x in (%1.$$$) do down %%x /P /F /Q
del %1.$$$

and for /f is one little bit of the for command. so much i dont understand yet :)

===============
Security Forums
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top