Wednesday, February 27, 2013

Batch File Looping - Route, Ping, …

You create a batch file called route.bat or route.cmd and it contains something similar to the following:

echo off
Route add MASK

When you run it as an Administrator it never finishes. You remove the “echo off” to see what is going on. You run it again and see it in an endless loop. When you cut and paste the command “route add…” in an Administrative command prompt  it works as expected but your batch file keeps looping.


Never name your batch file the same name as the executable it runs.

The reason in the example is the naming of the batch file is “route.” and your batch file is calling out to run the command “route”, It is executing itself in a never ending loop. Renaming the batch file something other than “route” and it will work fine.

Happy Batch Creation!


  1. Exactly the problem I had. Changed the name and now works perfectly. Many thanks. Charlie