title: Windows CMD.exe "The system cannot find the path specified."
body: <h1>Solved by restoring Windows to previous state</h1>
  
  <h2>The message (The system cannot find the path specified.) shows...</h2>
  
  <p>1) When i open new CMD (Win+R => cmd). It starts with introduction. (on line 3) </p>
  
  <pre><code>Microsoft Windows [Version 6.1.7601]
  Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
  The system cannot find the path specified.
  
  C:\Users\ViliamKopecky&gt;
  </code></pre>
  
  <p>2) When i execute some command like <code>cmd /C dir</code> (or <code>cmd /C php -v</code> or whatever) (on line 2)</p>
  
  <pre><code>C:\Users\ViliamKopecky&gt;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&gt;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
  </code></pre>
  
  <p>3) (the most annoying) when i run <code>exec</code> function from PHP or Node.js or probably any scripting lang. (which are probably runned from inside as <code>cmd /C &lt;command&gt;</code>)</p>
  
  <h2>The message does not show...</h2>
  
  <p>1) when i execute the command right from the cmd (or mingw, ...)</p>
  
  <pre><code>C:\Users\ViliamKopecky&gt;dir
   Volume in drive C is Windows7_OS
   Volume Serial Number is 8230-1246
  
   Directory of C:\Users\ViliamKopecky
  </code></pre>
  
  <hr>
  
  <p>Let's start with simple command from cmd.</p>
  
  <p><code>php -r "exec('dir', $stdout, $stderr); print(implode(\"\n\", $stdout), $stderr);"</code></p>
  
  <p>and the result is like this <em>(the directory test is empty - that is correct)</em>:</p>
  
  <pre><code>E:\test&gt;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    &lt;DIR&gt;          .
  09.11.2012  22:42    &lt;DIR&gt;          ..
                 0 File(s)              0 bytes
                 2 Dir(s)  13 495 296 000 bytes free
  int(1)
  </code></pre>
  
  <p>Which shows that the command <code>dir</code> has is executed from php correctly. Only thing thats wrong is the second line - <strong>The system cannot find the path specified.</strong> - that should not be there.</p>
  
  <p>This message is output by exec from <strong>PHP</strong> (and also from <strong>Node.js</strong> as <code>require('child_process').exec("dir", function(err, stdout, stderr) {console.log(stderr)});</code>)</p>
  
  <p>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 <code>exec</code> functions.</p>
  
  <p><strong>How to get rid of that annoying message?</strong> Thanks</p>