Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need a sample batch file that will ping several servers and send the results to a log file, with a time stamp as well.
If possible, it would be great if all i had to do was just plug in the IP addresses and move along. Please help me out if you can, i would appreciate it.

Try this:
:: multiIP.bat
@echo offfor /f "tokens=*" %%I in (IPlist) do call :pinger %%I
goto :eof:pinger
echo %TIME% >> pingLOG
ping %1 >> pingLOG
:: DONE
If at first you don't succeed, you're about average.M2

Thanks for the help, now another question is do i have to create the log file first, or will it save it to it automatically?

It creates / appends the log file.
If you want a fresh log file for each "run" just change the first line to:
@echo off > pingLOG
which wipes the existing pingLOG
If at first you don't succeed, you're about average.M2

Ok, i copied and pasted the exact batch into notepad and saved it as multiIP.bat. I did substitute an actual IP address for (IPlist). Is that all i have to do? Because it's not working. Please let me know what else may need to be changed.
Thanks

Hi,
IPlist is the name of a file containing the IPs to ping.
Try that.
If at first you don't succeed, you're about average.M2

ok, and just to be sure, should i keep the parenthesis with IPlist, and also do i need to put the path name with it, or just the IPlist?
Thanks.

Hi,
You need the parentheses.
And you need the path to the file if it's not in the current directory.
in (c:\temp\IPlist) do
If at first you don't succeed, you're about average.M2

Ok, i hope this is the last question, cause i hate to keep bothering you, but it's still not working.
This is what i have in my "multiIP.bat" program:
@echo off
for /f "tokens=*" %%I in (C:\Documents and Settings\Ben\Desktop\batch\IPlist.txt) do call
:pinger %%I
goto :eof:pinger
echo %TIME% >> C:\Documents and Settings\Ben\Desktop\batch\pingLOG.txt
ping %1 >> C:\Documents and Settings\Ben\Desktop\batch\pingLOG.txt
::DONEI created a folder called "batch" on my desktop to hold these files. Let me know what i need to change, what needs to be added, etc.
Thanks again, you're a big help.

Hi,
Because of the spaces in the path, I beleive you'll need:
("C:\Documents and Settings\Ben\Desktop\batch\IPlist.txt")
The same goes for the other two instances of the path, in the :pinger.
If at first you don't succeed, you're about average.M2

Man, i don't understand, it's still not working. What should the ip list have, just the addresses, or should it say ping in front of them, or anything else i'll need?
Also, should i leave the ".txt" with the file names?

The list of IPs needs just the numerical IPs, like this:
127.0.0.1
122.22.3.15In answer to your last question, you can use any legal file name, with or without an extension.
Are you getting errors?
No pingLOG.txt?
Crash?
If at first you don't succeed, you're about average.M2

Open a cmd prompt and run it so you can see what it's doing.
If at first you don't succeed, you're about average.M2

It says it cant' find IPlist, even though i have it in the same folder as the .bat file. I've also tried putting the path with it, but that didnt' work either. very strange.

After the first line, which is:
@echo off
put these and post what you get:
type IPlist
pause
If at first you don't succeed, you're about average.M2

It's bedtime for Buckwheat.
I'll check in tomorrow.
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |