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
echo off & cls
set /p IP=Enter your IP Address :
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 >nul
GoTo top

About Albin Sebastian

I am a Technology Blogger, System Administrator by profession and webmaster by passion. Technology blogger, Active in Online and offline tech communities.

Check Also

Batch Script to check DNS

Batch Script to check DNS results from different DNS Servers

Normal DNS propogation maximum time is 24 hr to 48 hrs. but usually servers start …


  1. Dear Albin,
    Really it is useful for monitoring purpose and reduce the stress of  monitoring person. I checked it is working  fine
    Jain Scaria

  2. @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

  3. @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

  4. hi i want to ping multiple IP for ex ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4
    ping -n 4

    ten what how it will work.. please help

  5. @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 >nul” from the script, It is just for a sleep function