• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 775
  • Last Modified:

Script commands to test Internet connection

Running Windows 7 Pro on HP z210.

I am battling my internet provider.  My connection disconnects frequently.
I have to keep entering the command:  ping www.yahoo.com to see if the connection has failed.
I am working with the vendor to determine if the problem can be solved or whether I have to find a new Internet vendor.

In the meantime...  I don't want to have to keep entering the ping command.
I am aware there is a robust scripting language for Windows 7.

Q1.) What commands would I put into a script to determine if the internet  connection has failed?

Q2.)  what script commands would execute an mp3 file if the connection has failed?
2 Solutions
Dan CraciunIT ConsultantCommented:
ping www.yahoo.com -t

This will keep pinging yahoo.

Try this, create .bat file, replace c:\temp\myfile.mp3 with path to mp3 file you want to play.

@setlocal enableextensions enabledelayedexpansion
@echo off
set target=%1


ping -n 1 !target! >nul: 2>nul:
if  !errorlevel!==0  (
    echo Response Recieved from !target!
) Else (
    echo Lost connection to !target!
start C:\temp\myfile.mp3
    goto :eof

goto :testconnection
donpickAuthor Commented:
Thank you for your fast responses
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now