This is a very simple batch file whch will alert you if a system is up or down based on values passed to it by playing a sound in windows media player , i created it because a colleague was telling me that his mac book did this by default , and it seemed like a handy tool if you were waiting for a server to go down or come up.
i called the batch file bping.bat and this is an example of a command line to run the tool.
I also added the option to put an interpackket delay in so that i could use it to test for high latency wan link packets being dropped
bping.bat 192.168.100.100 1000 up
This will ping 192.168.100.100 with a inter packet delay of 1000 milliseconds and will play a sound when the device responds to ping.
Echo off
CLS
Echo you are pinging %1 with a delay of %2 milliseconds between pings
echo and will be notified if packets are %3
Pause
CLS
If %3 == up Goto :Pingup
If %3 == Down Goto :Pingdown
:PingUP
PING %1 -n 1 | FIND "TTL=" >NULL
set pingresult=%errorlevel%
Echo on
PING %1 -n 1
Echo off
sleep -m %2
IF %pingresult% EQU 1 Goto :PingUP
Start "C:\program Files\Combined Community Codec Pack\MPC\Mplayer.exe /Play /Close" "C:\windows\Media\Notify.wav"
Goto PingUP
:PingDown
PING %1 -n 1 | FIND "TTL=" >NULL
set pingresult=%errorlevel%
Echo on
PING %1 -n 1
Echo off
sleep -m %2
IF %pingresult% EQU 0 Goto :PingDown
Start "C:\program Files\Combined Community Codec Pack\MPC\Mplayer.exe /Play /Close" "C:\windows\Media\Windows Exclamation.wav"
Goto PingDown
No comments:
Post a Comment