Note that to change the color individually per line, you need some help.
The rest is basically this:
//salvar como cping.bat ou coisa do tipo
//uso: cping <IP>
@ECHO off
:top
PING -n 1 %1% | find "%1%"
IF NOT ERRORLEVEL 1 GOTO yes
IF ERRORLEVEL 1 GOTO no
:yes
COLOR 2
ECHO Ping OK
GOTO top
:no
COLOR 4
ECHO Ping FAIL
GOTO top
Note that in case the color of the entire window changes, to make individual lines of different colors, it is necessary to change the COLOR
by some external utility.
Obviously it's just a sketch, but it already has the complete logic for you to adapt as you see fit.
Coloring the Output
Here is a utility that makes% color:%
link
Follow the code tailored for colored lines separately, using the utility mentioned:
@ECHO off
:top
CECHO {08}
PING -n 1 %1% | find "%1%"
IF NOT ERRORLEVEL 1 GOTO yes
IF ERRORLEVEL 1 GOTO no
:yes
CECHO {0A}Ping OK
GOTO top
:no
CECHO {0C}:Ping FAIL
GOTO top