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

前端 未结 3 1644
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 17:03

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          


        
相关标签:
3条回答
  • 2021-01-20 17:23

    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

    0 讨论(0)
  • 2021-01-20 17:44

    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
    
    0 讨论(0)
  • 2021-01-20 17:45

    How to diagnose this error:

    'ping' is not recognized as an internal or external command operable 
    program or batch fie. 
    

    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 program cmd.exe locate ping.exe?

    You can print out your path variable on the commandline like this:

    echo %PATH%
    

    Which prints for me:

    C:\WINDOWS;C:\WINDOWS\system32;C:\Program Files\jZip;C:\MinGW\bin
    

    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

    1. You didn't specify C:\WINDOWS\System32 in your path variable. Make sure it is there.
    2. ping.exe is missing. Find out who deleted it and put it back.
    3. ping.exe is corrupt. Run it where it sits: C:\WINDOWS\System32\ping.exe, or replace ping.exe.
    4. You have overridden the PATH variable before you look for it.
    0 讨论(0)
提交回复
热议问题