I am trying to run this command in windows:
ping -n 5 127.0.0.1 > nul
I get the error:
'ping' is not recognized as an internal or external command operable
program or batch fie.
Why can't windows find ping? Here is my script where it does not work:
@ECHO OFF
::set path
SET path=M:\\5.bmp
:findfile
IF EXIST %path% (
ECHO File found
) ELSE (
ECHO File not found
ping -n 5 127.0.0.1 > nul
goto findfile
)
How to diagnose this error:
Because your
path
environment variable does not contain the directory that points to the executable:ping.exe
. So the question becomes why can't your command line programcmd.exe
locateping.exe
?You can print out your path variable on the commandline like this:
Which prints for me:
The above string is delimited by semicolons(
;
). Notice the element called:C:\WINDOWS\System32
, that is the element that defines where ping.exe can be located.Solutions
C:\WINDOWS\System32\ping.exe
, or replaceping.exe
.Hi to fix "ping" please follow below steps
Go to Properties in My computer
Advanced system settings ----->Advanced -----> Environment Variables Select 'PATH' from the list of system variables and edit and set PATH to c:\windows\system32 ; this will solve your problem.
-----> if still u have a problem, do the below steps...
Control Panel --> System and security --> Windows Firewall --> Advanced settings --> Inbound rules --> New rule --> custom rule
in Protocol and ports: Protocol: ICMPv4 on the same panel go to customize, choose "Specific ICMP types", check the box "echo request"
The rest is trivial; go to next... next... and save it.
You should be done. This box responds ping from this point on.
Cheers
Prasad
You have overridden the
PATH
environment variable, so the command processor can no longer find theping
executable.The fix is nice and simple - just use a different variable name!
Please note that if you genuinely wanted to set the
path
environment variable, you should append to it like so: