Ping multipal IP with background Colour changes in windows

Rajat Sehgal
Rajat Sehgal used Ask the Experts™
on
Hello Experts,
how does make a bat file for continuous Ping multipal IP with background Colour changes ?
for example:-
start ping -t 192.168.207.11 -l 0
start ping -t 192.168.207.12 -l 0
start ping -t 192.168.207.13 -l 0
start ping -t 192.168.207.14 -l 0
start ping -t 192.168.207.15 -l 0
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
Unless this is purely an educational activity trying to learn more about DOS scripting, I would use one of the many freeware Windows ping utilities for this task.  Here are a couple that are worth a look and allow you to see status of a set of nodes.



»bp
Rajat SehgalFounder Enhance Technology

Author

Commented:
Sir i need implement with DOS scripting only.
IT / Software Engineering Consultant
Top Expert 2016
Commented:
See if this gets you started.  There is a driver bat file (pingstart.bat), and then a worker one (pingloop.bat).  Place a list of the IPs to be monitored into the "iplist.txt" file, and then run the "pingstart.bat" file to launch a worker window for each IP in the file.  Color will change depending on status from the PING command.

There is no easy way to see the full output of the PING command in the windows since we need to capture that internally in the BAT file and look at it to determine if the PING failed.  For successful PINGs we see one line from the PING command, for fails we see none.

You may want to add a delay in the PING loops and not monitor constantly, could slow down the system running all this.

***** PINGSTART.BAT *****
@echo off
setlocal

set "iplist=iplist.txt"

if not exist "%iplist%" (
    echo Missing IPLIST file "%iplist.txt"
    exit /b
)

for /f "usebackq tokens=*" %%i in ("%iplist%") do (
    start pingloop.bat %%~i
)

Open in new window

***** PINGLOOP.BAT *****
@echo off
setlocal

set colorUp=2F
set colorDown=4F

if "%~1" EQU "" (
    exit /b
)

title IP:%~1 - Status:

:Loop
    echo %DATE% %TIME%
    ping -n 1 -l 0 %~1 | find "TTL=" && (
        color %colorUp%
        title IP:%~1 - Status:UP
    ) || (
        color %colorDown%
        title IP:%~1 - Status:DOWN
    )
    goto :Loop

Open in new window

***** IPLIST.TXT *****
192.168.0.1
192.168.0.22
192.168.0.222

Open in new window


»bp
Rajat SehgalFounder Enhance Technology

Author

Commented:
Thank You Sir.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial