title: Not able to execute copy command in bat from PHP
body: <p>I am trying a really simple thing in PHP. I want to execute an external bat file from PHP script, which is invoked from web server (Apache with WAMP). Following is the content of bat file named savereport.bat</p>
  
  <pre><code>echo %PATH% &gt; C:\project\mypath.txt
  cp D:\books\Ant\1.pdf D:\books\Ant\2.pdf
  </code></pre>
  
  <p>The bat file when executed manually works fine, it creates mypath.txt in C:\project directory and 1.pdf is copied to 2.pdf correctly.</p>
  
  <p>However, when I run the same bat file from PHP with system(), only the first statement completes, which means it does create C:\project\mypath.txt, but strangely it does not copy 1.pdf to 2.pdf.</p>
  
  <p>This is the PHP code I am using</p>
  
  <pre><code>&lt;?php
  system('C:\wamp\www\savereport.bat');
  ?&gt;
  </code></pre>
  
  <p>I have also tried exec(), passthru, same result in all the case. Please help.</p>