ping and output a list of ip's

I need something fairly simple, I just need to ping a list of computers on my text file (printers.txt) with a -a argument to resolve the hostname. then output that to a simple text file, output.txt

I have tried the following but the result was that I had 4k instances of cmd.exe in my processes.

@echo off

type nul>pass.txt

type nul>fail.txt

for /f %%a in (printers.txt) do call :ping %%a

goto :EOF


echo testing %1

ping %1|find /i "TTL=">nul

if %errorlevel%==0 echo pass&echo %1>>pass.txt

if %errorlevel%==1 echo FAIL&echo %1>>fail.txt

again, I ended up with about 4k instances of cmd.exe and find.exe (a grep instance of some sort).

I'm not real smart but I would like some assistance on this. I just want a very simple ping -a and output to a text or.csv file.
AlfonsoPinaSr. Systems AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It's not so easy to accomplish this with a batch file.
I have created a Visual Basic script for this task.

Unpack and copy the files to a new directory.

Place the IP-addresses from "printers.txt" in "PingComputer.txt", one IP-address per line.
Run "PingComputer.cmd" which will execute "PingComputer.vbs" with cscript.exe
The output will be written to "PingComputer_Output.csv" in the same directory as the script.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlfonsoPinaSr. Systems AdministratorAuthor Commented:
Thanks, I'm not very good at coding, a little c++ and java but no vbs at all. This solution helped me, I will probably use it all week long. Thanks again.
You are very welcome and good to know that it's working fine. Thanks for the grade.
Steve KnightIT ConsultancyCommented:
I suspect your batch file you might have called PING.cmd or PING.bat perhaps and therefore it looped and re-ran itself?

I know you have an answer, but for anyone wanting a batch solution too I have a few here of mine, a variation of the one I use a lot when no other methods are available to monitor certain kit is reachable and email me if not...

AlfonsoPinaSr. Systems AdministratorAuthor Commented:
thanks Steve, I hadn't thought of that but i suspect you are correct. I will take a look at my batch file and see if I can put a restriction on it somehow.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.