nul 我收到错误: 'ping' is not recognized as an internal or e-6ren">
gpt4 book ai didi

command-line - Windows 批处理错误 : "' ping' is not recognized as an internal or external command operable program or batch file."

转载 作者:行者123 更新时间:2023-12-01 08:33:31 25 4
gpt4 key购买 nike

我正在尝试在 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? 这是我的脚本不起作用的地方:
@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可执行。

修复既好又简单 - 只需使用不同的变量名称!

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

:findfile
IF EXIST %MyPath% (

请注意,如果您真的想设置 path环境变量,你应该像这样附加到它:
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

关于command-line - Windows 批处理错误 : "' ping' is not recognized as an internal or external command operable program or batch file.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15088857/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com