Windows Command Line Ping Replacement

So the windows version of ping is really stupid.

I was writing a batch script to mount up a network share that involved checking to ensure my NAS unit was turned on. The script is scheduled to run after the computer resumes.

What I found out is that the built in version of Ping.exe is terrible at telling you whether the ping has returned successfully or not. I was checking the ERRORLEVEL – %ERRORLEVEL% variable to find out what ping was returning. It should be 0 for success and 1 or higher for a failure.

What I found was, i was getting replies from the local pc (dunno why, leave me a comment if you know) and ping was reporting a success even though the correct pc failed to reply. The solution?
Replace the Windows ping.exe with Fping. It has a lot more options and appears – from some initial quick tests – to correctly report the errorlevel.

Kudos to Wouter Dhondt for developing it. I’ll update this post with any more news!

 

image Fping vs Ping errorlevel return values

7 thoughts on “Windows Command Line Ping Replacement

  1. Kirrus

    @Nick, in case you didn’t see it, the above post was written by Garreth.. look out for the byline at the bottom of the post 🙂

    I need to modify the theme to put that more prominently at the top sometime..

  2. Russ

    This is a really old thread, but MS’s networking just gets worse and worse. (And yes, I use Linux whenever I can.) They keep on making stupid changes to the networking in hopes that computer illiterate people will be able to get network access even if they do everything wrong. Some of the more frustrating ones:

    * Windows now ARPs for its own address when attaching to the network. If it receives a reply, it assumes that address is already taken and networking just doesn’t work any more. Furthermore, it is impossible to get MS to pass any network traffic even if you change your address. Nothing works until you attach to a different network and then back to the other network with a different address. This really creates havoc if someone left proxy ARP turned on somewhere.

    * If there are two interfaces on a Windows machine, network A with a default gateway and network B without and you attempt to reach a device on network B and that node does not reply, Windows starts sending all traffic for that node out the interface of network A. Even if that node becomes available on network B, Windows keeps sending that traffic out interface A until interface A gets shut down or possibly if that node sends traffic to the Windows machine.

    * Ping assumes that every ICMP message coming back to it is a successful ping. This includes destination unreachables and all sorts of other failures.

    * Ping returns a reply (what is talked about above) if your workstation ARPs for the address and doesn’t receive a response. The reply is from itself as a Destination Host Unreachable.

  3. Bruce Stoor

    Not that I’m so much a Windows fan by choice but you may have noticed that the vast majority of computers on the planet run Windows. Those of us in the real business world have 2 choices
    1. Work with and endure Windows’ shortcomings
    2. Find a new job.
    At my age option 1 is really the only viable option, I got mouths to feed.

Leave a Reply

Your email address will not be published. Required fields are marked *