php Windows CMD.exe “系统找不到指定的路径。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13316682/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows CMD.exe "The system cannot find the path specified."
提问by ViliamKopecky
Solved by restoring Windows to previous state
通过将 Windows 恢复到以前的状态来解决
The message (The system cannot find the path specified.) shows...
消息(系统找不到指定的路径。)显示...
1) When i open new CMD (Win+R => cmd). It starts with introduction. (on line 3)
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) When i execute some command like cmd /C dir(or cmd /C php -vor whatever) (on line 2)
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) (the most annoying) when i run execfunction from PHP or Node.js or probably any scripting lang. (which are probably runned from inside as cmd /C <command>)
3)(最烦人的)当我exec从 PHP 或 Node.js 或任何脚本语言运行函数时。(这可能是从内部运行的cmd /C <command>)
The message does not show...
消息不显示...
1) when i execute the command right from the cmd (or mingw, ...)
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
Let's start with simple command from cmd.
让我们从 cmd 中的简单命令开始。
php -r "exec('dir', $stdout, $stderr); print(implode(\"\n\", $stdout), $stderr);"
php -r "exec('dir', $stdout, $stderr); print(implode(\"\n\", $stdout), $stderr);"
and the result is like this (the directory test is empty - that is correct):
结果是这样的(目录 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)
Which shows that the command dirhas is executed from php correctly. Only thing thats wrong is the second line - The system cannot find the path specified.- that should not be there.
这表明该命令dir已从 php 正确执行。唯一错误的是第二行 -系统找不到指定的路径。- 那不应该在那里。
This message is output by exec from PHP(and also from Node.jsas require('child_process').exec("dir", function(err, stdout, stderr) {console.log(stderr)});)
此消息由PHP的 exec 输出(也来自Node.jsas require('child_process').exec("dir", function(err, stdout, stderr) {console.log(stderr)});)
When I execute command right from cmd (or mingw, etc.) it executes correctly without the message. Environment variable PATH seem ok. Problem is just executing from script environment through execfunctions.
当我直接从 cmd(或 mingw 等)执行命令时,它会正确执行而没有消息。环境变量 PATH 似乎没问题。问题只是通过exec函数从脚本环境执行。
How to get rid of that annoying message?Thanks
如何摆脱那个烦人的消息?谢谢
回答by s3v1
The problem is that some program has been set to autorun when you run cmd.exe. In my case it was ANSICON that was installed... and then I moved the file without properly uninstalling.
问题是当您运行 cmd.exe 时,某些程序已设置为自动运行。就我而言,安装的是ANSICON...然后我移动了文件而没有正确卸载。
I found a solution in this blog post:
我在这篇博文中找到了一个解决方案:
http://carol-nichols.com/2011/03/17/the-system-cannot-find-the-path-specified/
http://carol-nichols.com/2011/03/17/the-system-cannot-find-the-path-specified/
The short version is to find
简短的版本是找到
HKCU\Software\Microsoft\Command Processor\AutoRun
HKCU\Software\Microsoft\Command Processor\AutoRun
and clear the value.
并清除该值。
回答by Joseph Keeler
This actually looks like a startup error with PHP, not with your code. Does
这实际上看起来像是 PHP 的启动错误,而不是您的代码。做
php -r "echo 1;"
php -r "echo 1;"
also throw the same error? If so, your php.ini file or an include may be pathed incorrectly.
也抛出同样的错误?如果是这样,您的 php.ini 文件或包含的路径可能不正确。
php -i
php -i
should give you more info.
应该给你更多的信息。
回答by Jess
I think you should try this out ! I had the same issue and solved it like this :
我想你应该试试这个!我遇到了同样的问题并像这样解决了它:
ok type : cd\windows\system32 After that you will see this: System32/: Type what you want (ex:ipconfig): System32: ipconfig Then that should do it ! :)
ok type : cd\windows\system32 之后你会看到: System32/: Type what you want (ex:ipconfig): System32: ipconfig 然后就可以了!:)

