Friday, August 23, 2019

windows - Ping every IP address in a text file?


Let´s say I have here a text file with some computer names (each line == 1 name):


computerA
computerB
computerC
...

Is it possible to create a batch file that is pinging all of these computers? And actually a ping is a big output. I don't need the time or other information; I just would like to know reachable or not. Any ideas?




It´s working now! The problem was like fox said, that I named my batch file as ping.bat and ping is also a command so this did not work out. I renamed my batch file and now everything is fine.


Answer



Try this:


@echo off
for /f "delims=" %%a in (computerlist.txt) do ping -n 1 %%a >nul && (echo %%a ok) || (echo %%a failed to respond)
pause

If you have to use a filename or path with spaces or odd characters then Instead of (computerlist.txt) use ( ' type "c:\folder\computer file.txt" ' )


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...