Windows批处理错误:“'ping'不被识别为内部或外部命令可操作程序或批处理文件". [英] Windows Batch error: "'ping' is not recognized as an internal or external command operable program or batch file."
本文介绍了Windows批处理错误:“'ping'不被识别为内部或外部命令可操作程序或批处理文件".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Windows中运行此命令:
I am trying to run this command in windows:
ping -n 5 127.0.0.1 > nul
我得到了错误:
'ping' is not recognized as an internal or external command operable
program or batch fie.
为什么Windows找不到ping命令?这是我的脚本无法正常工作:
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
)
推荐答案
您已覆盖PATH
环境变量,因此命令处理器无法再找到ping
可执行文件.
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% (
请注意,如果您确实想设置path
环境变量,则应像这样追加:
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
这篇关于Windows批处理错误:“'ping'不被识别为内部或外部命令可操作程序或批处理文件".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文