ping and output a list of ip's

Posted on 2014-08-15
Last Modified: 2014-08-22
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.
Question by:AlfonsoPina
    LVL 11

    Accepted Solution

    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.

    Author Closing Comment

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

    Expert Comment

    You are very welcome and good to know that it's working fine. Thanks for the grade.
    LVL 43

    Expert Comment

    by:Steve Knight
    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...


    Author Comment

    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.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now