21

通过将 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)(最烦人的)当我exec从 PHP 或 Node.js 或任何脚本语言运行函数时。(可能是从内部运行的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 正确执行。唯一错误的是第二行 -系统找不到指定的路径。- 那不应该在那里。

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

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

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

4

4 回答 4

52

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.

I found a solution in this blog post:

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

and clear the value.

于 2012-11-12T12:00:20.190 回答
0

This actually looks like a startup error with PHP, not with your code. Does

php -r "echo 1;"

also throw the same error? If so, your php.ini file or an include may be pathed incorrectly.

php -i

should give you more info.

于 2012-11-09T22:48:38.030 回答
0

此消息可能意味着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

参考

于 2020-12-30T10:53:30.120 回答
-3

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

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

于 2013-12-30T05:38:49.117 回答