Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 845859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:31:21+00:00 2026-05-15T06:31:21+00:00

I want to continuously ping a server and see a message box when ever

  • 0

I want to continuously ping a server and see a message box when ever it responds i.e. server is currently down. I want to do it through batch file.

I can show a message box as said here Show a popup/message box from a Windows batch file

and can ping continuously by

ping <servername> -t

But how do I check if it responded or not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:31:22+00:00Added an answer on May 15, 2026 at 6:31 am

    The following checklink.cmd program is a good place to start. It relies on the fact that you can do a single-shot ping and that, if successful, the output will contain the line:

    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
    

    By extracting tokens 5 and 7 and checking they’re respectively "Received" and "1,", you can detect the success.

    @setlocal enableextensions enabledelayedexpansion
    @echo off
    set ipaddr=%1
    :loop
    set state=down
    for /f "tokens=5,6,7" %%a in ('ping -n 1 !ipaddr!') do (
        if "x%%b"=="xunreachable." goto :endloop
        if "x%%a"=="xReceived" if "x%%c"=="x1,"  set state=up
    )
    :endloop
    echo.Link is !state!
    ping -n 6 127.0.0.1 >nul: 2>nul:
    goto :loop
    endlocal
    

    Call it with the name (or IP address) you want to test:

    checklink 127.0.0.1
    checklink localhost
    checklink nosuchaddress
    

    Take into account that, if your locale is not English, you must replace Received with the corresponding keyword in your locale, for example recibidos for Spanish. Do a test ping to discover what keyword is used in your locale.


    To only notify you when the state changes, you can use:

    @setlocal enableextensions enabledelayedexpansion
    @echo off
    set ipaddr=%1
    set oldstate=neither
    :loop
    set state=down
    for /f "tokens=5,7" %%a in ('ping -n 1 !ipaddr!') do (
        if "x%%a"=="xReceived" if "x%%b"=="x1," set state=up
    )
    if not !state!==!oldstate! (
        echo.Link is !state!
        set oldstate=!state!
    )
    ping -n 2 127.0.0.1 >nul: 2>nul:
    goto :loop
    endlocal
    

    However, as Gabe points out in a comment, you can just use ERRORLEVEL so the equivalent of that second script above becomes:

    @setlocal enableextensions enabledelayedexpansion
    @echo off
    set ipaddr=%1
    set oldstate=neither
    :loop
    set state=up
    ping -n 1 !ipaddr! >nul: 2>nul:
    if not !errorlevel!==0 set state=down
    if not !state!==!oldstate! (
        echo.Link is !state!
        set oldstate=!state!
    )
    ping -n 2 127.0.0.1 >nul: 2>nul:
    goto :loop
    endlocal
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MediaPlayer playing a file, and I want to continuously write logging
I want to continuously keep sending update to server using jquery. The interval will
I have a node.js script on my server that I want to run continuously
I'm using httpclient to download multiple small files from server continuously. So I want
I want to read file continuously like GNU tail with -f param. I need
I want to run a batch file which contain command arp -d * (
I want to make a little tk app that continuous ping an ip and
I want to rotate imageview with continuously looping on android.my code rotate is working
I want to create some kind of AJAX script or call that continuously will
I have a process which gives me continuously output in Screen. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.