windows - IF STATEMENT for PINGS -
i work in small department has multiple users in other external offices , have made basic (windows) ping command batch script pings each office check online. run .bat file , leave in corner of screen.
if ping fails turns background red, if works stays blue. here content:
@echo off color 97 :start echo external check ping www.google.com if %errorlevel% equ 0 color 97 if %errorlevel% equ 1 color 47 echo site check ping x.x.x.x if %errorlevel% equ 0 color 97 if %errorlevel% equ 1 color 47 echo site b check ping x.x.x.x if %errorlevel% equ 0 color 97 if %errorlevel% equ 1 color 47 echo site c check ping x.x.x.x if %errorlevel% equ 0 color 97 if %errorlevel% equ 1 color 47 echo site d check ping x.x.x.x if %errorlevel% equ 0 color 97 if %errorlevel% equ 1 color 47 goto start
i pretty new scripting apologies stupid errors. if has suggestions improve welcome them. hope helps people though! rob
try:
@echo off :color 97 :start echo external check ping www.google.com call :color echo site check ping www.yahoo.com call :color echo site b check ping 127.0.0.1 call :color echo site c check ping www.nowhere.com.fail call :color echo site d check ping www.failfail.com.fail call :color goto start :color if %errorlevel% equ 0 ( color 97 ) else ( color 47 ) goto:eof
Comments
Post a Comment