21

Solved by restoring Windows to previous state

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)

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 -v or whatever) (on line 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 exec function from PHP or Node.js or probably any scripting lang. (which are probably runned from inside as cmd /C <command>)

The message does not show...

1) when i execute the command right from the cmd (or 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.

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):

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 dir has 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.

This message is output by exec from PHP (and also from Node.js as 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 exec functions.

How to get rid of that annoying message? Thanks

8

4 Answers 4

54

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.

9
  • 3
    ANSICON - yes, the problem stared after I installed it. Marking your answer as accepted. Thanks ;) Nov 12, 2012 at 15:22
  • 3 hours of research on where does my drush install error comes from and I ended up here after found that it failed at php exec, and yes it was ANSICON +1
    – user2509223
    Mar 18, 2014 at 11:38
  • 2
    Make sure you check HKLM\Software\Microsoft\Command Processor\AutoRun as well. Particularly if you have Clink.
    – Gui Ambros
    Mar 30, 2014 at 5:26
  • 2
    Thank you! I I had a leftover conda intializing hook that was producing this error and producing side effects somewhere really far away. Took me a while to track it down until I finally got here! Apr 25, 2019 at 15:19
  • 1
    In my case, it was HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun instead of HKCU\Software\Microsoft\Command Processor\AutoRun Aug 23, 2020 at 5:05
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.

1
  • This runs correctly C:\Users\ViliamKopecky>php -r "echo 1;" 1 Nov 9, 2012 at 23:02
0

This message can mean a path in the PATH enviromental variable doesn't exist.

The following PowerShell command will print missing paths.

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

e.g.

> ($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

References

-3

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 ! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.