Computing.Net > Forums > Programming > Batch to show error message if PING fails?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch to show error message if PING fails?

Reply to Message Icon

Name: CriticalPoint
Date: May 18, 2009 at 05:25:34 Pacific
OS: Windows XP Professional
Subcategory: Batch
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: CriticalPoint
Date: May 18, 2009 at 07:22:19 Pacific
Reply:

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.


0

Response Number 2
Name: Mechanix2Go
Date: May 18, 2009 at 08:01:05 Pacific
Reply:

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


0

Response Number 3
Name: CriticalPoint
Date: May 19, 2009 at 01:59:03 Pacific
Reply:

Perfection. Thanks Mechanix, you really know your stuff, huh!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch to show error message if PING fails?

how to set error control in this? www.computing.net/answers/programming/how-to-set-error-control-in-this/16841.html

Batch to Detect flashdrive in Vista www.computing.net/answers/programming/batch-to-detect-flashdrive-in-vista/17425.html

How to show HTML code in your posts www.computing.net/answers/programming/how-to-show-html-code-in-your-posts/9036.html