1.    31 Mar 2016 #1
    Join Date : Mar 2016
    Posts : 31
    Windows 10

    Batch file: Who can solve this mystery?


    I recenty migrated to Windows 10 from XP. Years ago, I made a batch file, ping.bat, to test my Internet connection and DNS server:

    ping 98.139.183.24
    ping yahoo.com
    ping nytimes.com
    pause

    It works fine in XP, but when I run it in Windows 10, it goes into an endless loop after reading the first line, without returning a result or going on to the next line. But if I open it in Notepad and copy and paste the text into a Window 10 Command Prompt window, it works fine--just like in XP. What's going on? A couple of other batch files I made for XP seem to work the same in Windows 10.
      My ComputerSystem Spec
  2.    31 Mar 2016 #2
    Join Date : Jul 2015
    Posts : 9,552
    Windows 10 Pro

    Run ping /?

    that will give you the options of how long to ping for.
      My ComputerSystem Spec
  3.    31 Mar 2016 #3
    Join Date : Oct 2014
    Trnava
    Posts : 2,983
    10.4 Home 1709 x64

    The bat file works just fine on mine PC, maybe a problem with your DNS server.
    Anyway, that webpage probably reports to your DNS, that it is down right now.
    Attached Thumbnails Attached Thumbnails capture_03312016_193835.jpg  
      My ComputerSystem Spec
  4.    31 Mar 2016 #4
    Join Date : Mar 2016
    Posts : 31
    Windows 10
    Thread Starter

    My question is: Why do I get one result (endless loop) if I run the .bat file in Windows 10, but a different result (works fine) if I paste the exact text of the batch file into a Windows 10 Command Prompt window?
      My ComputerSystem Spec
  5.    31 Mar 2016 #5
    Join Date : Oct 2014
    Trnava
    Posts : 2,983
    10.4 Home 1709 x64

    I see, that is funny, rename your file to something else, not ping.
      My ComputerSystem Spec
  6.    31 Mar 2016 #6
    Join Date : Mar 2016
    Posts : 31
    Windows 10
    Thread Starter

    That's the answer! Renaming the file makes it work in Windows 10! It worked fine in XP as ping.bat.
    Quote Originally Posted by jfniss View Post
    My question is: Why do I get one result (endless loop) if I run the .bat file in Windows 10, but a different result (works fine) if I paste the exact text of the batch file into a Windows 10 Command Prompt window?
      My ComputerSystem Spec
  7.    31 Mar 2016 #7
    Join Date : Oct 2014
    Trnava
    Posts : 2,983
    10.4 Home 1709 x64

    then the interpreter (cmd.exe) searches/probes the paths in the environment variable %PATH% for something that looks like ping ... and it does that by appending each suffix from %PATHEXT% which contains something like .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC. so, calling just ping from the ping.batleads to a search for ping.comping.exeping.bat and so on. The interpreter will find a ping.bat in the current working directory (your ping.bat) and calls it.
    So, you will have a nice recursion here: ping.cmd executes the first line, searches for "ping", finds "ping.cmd", executes the first line, searches for "ping", finds "ping.cmd", executes the first line, searches for "ping", finds "ping.cmd" ...
    Source: windows 7 - Why does the PING command in my batch file execute in a loop? - Super User

    I might actually use it as a prank, especially since April 1st is coming.
    Attached Thumbnails Attached Thumbnails capture_03312016_200234.jpg  
      My ComputerSystem Spec
  8.    31 Mar 2016 #8
    Join Date : Jul 2015
    Posts : 9,552
    Windows 10 Pro

    Quote Originally Posted by TairikuOkami View Post
    I see, that is funny, rename your file to something else, not ping.
    Brilliant!
      My ComputerSystem Spec

 


Similar Threads
Thread Forum
Solved Start a program from a batch file
4 Apps of mine run a batch file that -tries- to call/start and EXE program. These Batch files need to work with OS XP thru Win 10. Win 10 has a pop-up window asking user if its okay to run/execute my EXE. No other Win version does this and thus I...
Software and Apps
Can't download batch file
Can't download batch file "10services_default.bat" to solve windows 10 start menu problem.
General Support
Solved Writhing Batch File
Here is my batch file but it will not delete the file? Must be missing something :( del "C:\Users\Larry\AppData\Local\TractorParts\tractor\ConfigSetting" Trying to delete the ConfigSetting File
General Support
System Info Batch File
Hi Everyone, I thought it may be interesting to get input from others regarding this batch file. I was hoping for suggestions about: Information to add to the report. Ways of making the current code more efficient. Etc... A while back i...
Chillout Room
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 13:37.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums