I tried to put commands that return output into batch file. When I run the batch file it executes the command over and over until I cancel with CTRL+C.
I observed this behavior in Windows CE, Windows XP, Windows 7 and Server 2003. At first I thought I made a mistake with LDIFDE but the same thing goes for PING.
Is there something I missed with batch scripting?
The file contains one line:
ping google.com
I.think you named your script
ping.bat
orping.cmd
and it is calling itself.This happens because of a design decision that was introduced in DOS 2.0. On MS-DOS, Windows, and MS-DOS clones and derivatives, the current directory is first in the search path. When DOS is searching for a command it first checks to see if it an internal command, built into command.com (e.g. echo, copy) then it searches the filesystem. It always starts with the current directory, and then it looks in directories defined in the PATH variable.
You have a couple options:
ping.exe google.com
%SystemRoot%\system32\ping.exe