Solved Ping list of computers from file and disable service

February 5, 2012 at 19:41:25
Specs: Windows XP
Hi All,

long time follower but first time poster, so finally registered to this very helpful site and posting my question.

For last 2 days I am scratching my head creating batch file or vbs but not able to find any answer.

I want to ping list of computers from file and see which one's online with windows service "winmgmt" running AND
If it's running DISABLE service
echo everything into file for each run....

I can test individual machine and disable with below:
SC \\machine query winmgmt | FIND "STATE" | FIND "RUNNING"

sc config "winmgmt" start= disabled

Like to combine all in single batch file or vbs script since there are 500 machines.

Thanks in advance for reading and providing valuable inputs.


See More: Ping list of computers from file and disable service

Report •

February 6, 2012 at 05:42:55
You know if you kill WMI, a lot of admin (VB)scripts might break, right?

EDIT: You don't even need to check to see if it's running. Just disable the service and call it a day.

for /f %%a in (someList.txt) do sc \\%%a config "winmgmt" start= disabled

How To Ask Questions The Smart Way

Report •

February 6, 2012 at 17:02:12
Hi Razor2.3,

Yes I agree disabling winmgmt will break many things.. it was just an use for testing purpose..

Thanks for your input... sorry I think I haven't explain properly....

Your script works perfectly fine but it will show all 500 machines services as disabled even if it was disabled before and everytime I run batch it will show again success message.... That was the reason of checking if service is enable then only disable it and show machine name in log output.

Idea is to....
1. Check service running
2. Disable if it's running
3. Give machine name in logfile with date if possible..... output.txt

Thanks again...

I found something similar... but it's other way around..

set service = uvnc_service
for /F %%a in (c:\find.txt) do call :servicecheck %%a

sc \\%1 query %service% | FIND "RUNNING"

sc \\%1 start %service% && >> out.txt echo %1



Report •

February 7, 2012 at 15:21:16
✔ Best Answer
Well, if you want a list of servers that changed (Untested). . .
for /f %%a in (someList.txt) do ^
for /f %%b in ('sc \\%%a qc winmgmt ^| find "START_TYPE"  ^| find /v "4"') do ^
sc \\%%a config "winmgmt" start= disabled && echo Changed %%a >> out.txt
There's no checks to see why the PC wasn't updated. "Access denied" and "already disabled" are treated identically.

Side note: A disabled service can still be running. Disabling a service doesn't kill any running instance of that service; it only keeps new instances from starting.

How To Ask Questions The Smart Way

Report •

Related Solutions

February 7, 2012 at 16:08:15
Razor2.3....I tell you .... " YOU ARE GENIUS"....

last provided script exactly solves my problem and gives me require output in logfile...
you have save my another 2 days getting wasted with lots of headache in the end....

I have set your answer as BEST answer so this will also help others...

Users like you is my only reason visiting this site 10 times a day.....

Report •

Ask Question