繁体   English   中英

Windows CMD.exe “系统找不到指定的路径。”

[英]Windows CMD.exe "The system cannot find the path specified."

通过将 Windows 恢复到以前的状态来解决

消息(系统找不到指定的路径。)显示...

1) 当我打开新的 CMD (Win+R => cmd) 时。 它从介绍开始。 (在第 3 行)

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
The system cannot find the path specified.

C:\Users\ViliamKopecky>

2)当我执行一些命令时,如cmd /C dir (或cmd /C php -v或其他)(在第 2 行)

C:\Users\ViliamKopecky>cmd /C dir
The system cannot find the path specified.
 Volume in drive C is Windows7_OS
 Volume Serial Number is 8230-1246
...

C:\Windows\System32>cmd /C php -v
The system cannot find the path specified.
PHP 5.4.8 (cli) (built: Oct 16 2012 22:30:23)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

3)(最烦人的)当我从 PHP 或 Node.js 或任何脚本语言运行exec函数时。 (可能是从内部作为cmd /C <command>

消息不显示...

1)当我直接从 cmd(或 mingw,...)

C:\Users\ViliamKopecky>dir
 Volume in drive C is Windows7_OS
 Volume Serial Number is 8230-1246

 Directory of C:\Users\ViliamKopecky

让我们从 cmd 中的简单命令开始。

php -r "exec('dir', $stdout, $stderr); print(implode(\\"\\n\\", $stdout), $stderr);"

结果是这样的(目录 test 是空的 - 这是正确的)

E:\test>php -r "exec('dir', $stdout, $stderr); print(implode(\"\n\", $stdout), $stderr);"
The system cannot find the path specified.
 Volume in drive E is www
 Volume Serial Number is 0C99-95EC

 Directory of E:\test

09.11.2012  22:42    <DIR>          .
09.11.2012  22:42    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  13 495 296 000 bytes free
int(1)

这表明命令dir已从 php 正确执行。 唯一错误的是第二行 -系统找不到指定的路径。 - 那不应该在那里。

此消息由PHP的 exec 输出(也来自Node.js 的require('child_process').exec("dir", function(err, stdout, stderr) {console.log(stderr)});

当我直接从 cmd(或 mingw 等)执行命令时,它会正确执行而没有消息。 环境变量 PATH 似乎没问题。 问题只是通过exec函数从脚本环境exec

如何摆脱那个烦人的消息? 谢谢

问题是当您运行 cmd.exe 时,某些程序已设置为自动运行。 就我而言,安装的是ANSICON...然后我移动了文件而没有正确卸载。

我在这篇博文中找到了一个解决方案:

http://carol-nichols.com/2011/03/17/the-system-cannot-find-the-path-specified/

简短的版本是找到

HKCU\\Software\\Microsoft\\Command Processor\\AutoRun

并清除该值。

这实际上看起来像是 PHP 的启动错误,而不是您的代码。

php -r "echo 1;"

也抛出同样的错误? 如果是这样,您的 php.ini 文件或包含的路径可能不正确。

php -i

应该给你更多的信息。

此消息可能意味着PATH环境变量中的PATH不存在。

以下 PowerShell 命令将打印丢失的路径。

($env:path).Trim(";").Split(";") | ? {-not (test-path $_)}

例如

> ($env:path).Trim(";").Split(";") | ? {-not (test-path $_)}
C:\Program Files\CMake\bin
C:\Program Files\SDCC\bin
C:\Users\wjbr\AppData\Local\Programs\Microsoft VS Code\bin

参考

我想你应该试试这个! 我遇到了同样的问题并像这样解决了它:

ok type : cd\\windows\\system32 之后你会看到: System32/: Type what you want (ex:ipconfig): System32: ipconfig 然后就可以了! :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM