Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Batch error: "'ping' is not recognized as an internal or external command operable program or batch file."

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
)
like image 283
user648244 Avatar asked Nov 24 '25 14:11

user648244


2 Answers

You have overridden the PATH environment variable, so the command processor can no longer find the ping executable.

The fix is nice and simple - just use a different variable name!

:: set path
SET MyPath=M:\\5.bmp

:findfile
IF EXIST %MyPath% (

Please note that if you genuinely wanted to set the path environment variable, you should append to it like so:

REM Set temporarily for this session
SET PATH=%PATH%;C:\Some\Folder

REM Set permanently (but note - this change will not be made to this session)
SETX PATH=%PATH%;C:\Some\Folder
like image 120
RB. Avatar answered Nov 28 '25 01:11

RB.


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

like image 36
Prasad Avatar answered Nov 28 '25 00:11

Prasad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!