Viewed   150 times

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

2) When i execute some command like cmd /C dir (or cmd /C php -v or whatever) (on line 2)

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

C:WindowsSystem32>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:UsersViliamKopecky>dir
 Volume in drive C is Windows7_OS
 Volume Serial Number is 8230-1246

 Directory of C:UsersViliamKopecky

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

 Answers

1

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

HKCUSoftwareMicrosoftCommand ProcessorAutoRun

and clear the value.

Thursday, September 29, 2022
5

exec — Execute an external program

system — Execute an external program and display the output

shell_exec — Execute command via shell and return the complete output as a string

so if you don't need the output, I would go with exec.

Further details:

  • http://php.net/manual/en/function.exec.php
  • http://php.net/manual/en/function.system.php
  • http://php.net/shell_exec
Thursday, December 1, 2022
5

It seems that it is hardlinks which Cygwin uses a lot are not handled correctly by Docker. And in particular when Docker tries to commit an image it fails with "hcsshim::ImportLayer - cannot find the path" error.

I run in the same problem recently and after I got rid of the hardlinks in Cygwin installation I was able to commit the image without problems.

To get rid of the hardlinks I have zipped and unzipped Cygwin folder.

Tuesday, October 4, 2022
 
3

I faced this issue while running the kafka-server-start.bat command. I double checked to ensure that there was no spaces in the kafka binaries path as well as correct syntax in JAVA_HOME.

Finally realized that the issue was due to a space in the JAVA_HOME path.

C:Program FilesJavajdk1.8.0_144

There is a space between Program and Files. I changed the directory of Java and updated the JAVA_HOME variable to

C:Javajdk1.7.0_51

This change solved my issue. I used the setx command to change the value in JAVA_HOME.

setx -m JAVA_HOME "C:Javajdk1.7.0_51"
Wednesday, August 10, 2022
 
jondro
 
1

This shoul work:

exec("start /B php myscript.php");

Also close all standard streams at the very beginning of myscript.php:

fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);

If you want echo to still work, you can open a file for writing to stdout after closing the standard streams:

$STDIN = fopen('/dev/null', 'r');
$STDOUT = fopen('myscript.log', 'wb');
Thursday, September 29, 2022
 
stvar
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share