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

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

该消息(系统找不到指定的path。)显示…

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或其他)(第二行)

 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 execfunction或可能是任何脚本语言。 (这可能是从内部运行的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);"

结果是这样的(目录testing是空的 – 这是正确的)

 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。 唯一的错误是第二行 – 系统找不到指定的path。 – 那不应该在那里。

这个消息是由EXEC从PHP输出(也是从Node.js输出require('child_process').exec("dir", function(err, stdout, stderr) {console.log(stderr)});

当我从cmd(或mingw等)执行命令时,它没有消息就正确执行。 环境variablesPATH似乎没问题。 问题只是通过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

应该给你更多的信息。

我想你应该试试这个! 我有同样的问题,并解决这个问题:

确定键入:cd \ windows \ system32之后,你将会看到:System32 /:键入你想要的(例如:ipconfig):System32:ipconfig那么应该这样做! 🙂