Bat file for continuous Ping with background Colour changes
We are using ping command to monitor the networks, Sometimes we have to monitor multiple IP address with continuous ping in different windows. Normal command line is with a black colour background and white text. But it will be better to show a red window if the Request timed out. And the default success pings with a green background. Here is the script to do the ping with color output results.
What is happening in this Batch file?
Prompting an IP address and set to a variable named %IP%, and its pinging once with 32 bytes of data. If it is failed the background color will change to red. And display “Request timed out” then wait for some title . We used a self ping for sleep function. The code put it in loop so it will ping continuously.
:: Batch Script :: color Ping :: Code By Binbert.com echo off & cls set /p IP=Enter your IP Address : :top PING -n 1 %IP% | FIND "TTL=" IF ERRORLEVEL 1 (SET OUT=4F & echo Request timed out.) ELSE (SET OUT=2F) color %OUT% ping -n 2 -l 10 127.0.0.1 >nul GoTo top








September 14th, 2010 at 2:30 PM
Dear Albin,
Really it is useful for monitoring purpose and reduce the stress of monitoring person. I checked it is working fine
Regards,
Jain Scaria
November 18th, 2010 at 3:02 PM
@Albin
Really it is a good effort; ease of use and makes monitoring effortless
November 18th, 2010 at 3:04 PM
@albin
I forget to comment one more thing , while we giving the batch file name as ping.bat, it is not responding, otherwise no problem
Useful one
November 18th, 2010 at 3:09 PM
@mohan
Thanks for your command,
Dear readers …
Please don’t use ping.bat as the file name. because there is a “ping” command already working inside the batch file
February 25th, 2011 at 2:39 PM
nice one……….:)
March 15th, 2011 at 8:12 PM
How to use this color function in Ping -t ?
March 17th, 2011 at 11:47 AM
Color is a dos command to change the cmd colors. Here we changing colors Red and green according to ping error level
June 28th, 2011 at 9:01 PM
hi i want to ping multiple IP for ex ping -n 4 10.1.2.12
ping -n 4 10.1.2.13
ping -n 4 10.1.2.14
ping -n 4 10.1.2.21
ping -n 4 10.1.2.22
ping -n 4 10.1.2.23
ping -n 4 10.1.2.24
ping -n 4 10.1.2.25
ping -n 4 10.1.2.26
ping -n 4 10.1.2.27
ping -n 4 10.1.2.28
ping -n 4 10.1.2.31
ten what how it will work.. please help
July 1st, 2011 at 10:41 AM
@Avinash
Ping will happen only on a singl IP address. You can write a script to ping one by one..
Replace %IP% with the IP addressees which you want to ping.
you can remove “ping -n 2 -l 10 127.0.0.1 >nul” from the script, It is just for a sleep function
October 4th, 2011 at 3:04 AM
how are you, primary blog on fatlike loss. such a person helped.