Jump to content

[Batch] Ping Script ?


Recommended Posts

It is possible to make something like this ...


@ECHO OFF
Title Service Check
CD\
CLS

Rem Step 1:
Ping 95.76.53.219
echo Your connection to the 95.76.53.219 is %ms%
Pause

I want to show only the average Ms ...

it is possible ?

Link to comment
Share on other sites


[barely resisting the urge to simply answer your question "Yes, have a nice day :)]

@ECHO OFF
(Set "addr=95.76.53.219")
FOR /F "skip=10 tokens=4 delims==" %%G IN ('Ping %addr%') DO ECHO Your connection to %addr% is %%G
Pause

This does no error checking at all and assumes that ping returns the standard response and does not time out.

Reference: http://ss64.com/nt/for_cmd.html

Cheers and Regards

Link to comment
Share on other sites

Is there a particular reason why you are looking for the average round trip time from four pings with a one second timeout?

BTW I'd probably change the above example to this

@ECHO OFF & SETLOCAL ENABLEEXTENSIONS
(SET addr=95.76.53.219)
FOR /F "TOKENS=4 DELIMS==" %%# IN ('PING %addr%^|FIND "Average"') DO (
ECHO=Your connection to %addr% is%%#)
PAUSE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...