In Windows, if you have a command line executable with the same name as your bat filename, and the batch file contains this command, the batch file keeps looping since Windows will execute that .bat
file instead of the Windows command.
Example:
- Create the file
net.bat
on your desktop. - In your file, write this text:
net
Double-click the file, and it will keep looping.
The cause of this behaviour is the order of execution of the commands. The command you want to execute is in one of the folders in your path. But the batch file is in your current folder, so it gets executed first, causing the loop.