Batch to show error message if PING fails?

May 18, 2009 at 05:25:34
Specs: Windows XP Professional
Hi,

I have written a batch to ping Google (Internet Test) and then ping a server of ours (VPN Test) and the third thing I'd like to do is to check to see if a PDA is connected - Although I understand that this is a tough one so I've worked around it to be honest.

What I am now trying to do is to get my batch file to only proceed if the PINGS are sucessful, else the file should show an error of sorts, explaining which failed and what to do, then a pause and a loop to re-check connectivity after user interaction.

I have this so far:

-----------------------------------------------------------
@ECHO OFF
Title Service Check
Color F5
CD\
CLS

Echo.
Echo.
Echo. Service check - Please read:
Echo.
Echo. Upon pressing Return, the following tests will
Echo. be initiated. Please be patient whilst these
Echo. checks complete:
Echo.
Echo. 1. Ping a Server (VPNE Conectivity Test)
Echo.
Echo. 2. Ping the Internet (Internet Conectivity Test)
Echo.
Echo. 3. Check Active sync (PDA Conectivity Test)
Echo.
Echo.
Echo.
Echo. Please note:
Echo.
Echo. This file will process information below and will
Echo. automatically conduct it's tests. Please do not close
Echo. the window or press any keys until prompted to do so.
Echo.
Pause

Rem Step 1:
Ping server.name.com

Rem Step 2:
Ping Google.co.uk

Rem Step 3:
START /W "C:\Program Files\Microsoft ActiveSync\WCESMgr.exe"
Pause
-----------------------------------------------------------

I have no idea how to get the file to only proceed if the PING is okay.

Any ideas?


See More: Batch to show error message if PING fails?

Report •


#1
May 18, 2009 at 07:22:19
Or rather, how to get the file to throw an error if the PING is not returned.. I just realised how stupid that last comment sounded! lol.

Report •

#2
May 18, 2009 at 08:01:05
Ping server.name.com | find "Reply"
if errorlevel 1 echo NG && goto :eof


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#3
May 19, 2009 at 01:59:03
Perfection. Thanks Mechanix, you really know your stuff, huh!

Report •

Related Solutions


Ask Question