title: Batch file that opens adobe reader to print PDF doesn't end/close
body: <p>I have the following code in a batch file that is called by a PHP script using <code>shell_exec()</code>:</p>
  
  <pre><code>"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" 
  /t "D:\xampp\htdocs\instrument\app\webroot\Repair Tickets\%1.pdf"
  \\hnurenfp01\Accounts_FS-1128MFP
  </code></pre>
  
  <p>Parameter %1 is the filename that is sent as an argument to the batch file from the PHP script.</p>
  
  <p><strong>Observed behaviour:</strong></p>
  
  <ul>
  <li>PHP page successfully calls batch file with correct argument</li>
  <li>Two instances of AcroRd32.exe silently start on the server</li>
  <li>PDF file prints to network printer</li>
  <li>AcroRd32.exe instances do not end/close</li>
  <li>Batch file keeps running (until manually ending AcroRd32.exe processes)</li>
  <li>PHP script is left executing, therefore preventing the client machine to do anything further</li>
  </ul>
  
  <p><strong>Expected behaviour:</strong></p>
  
  <ul>
  <li>PHP page successfully calls batch file with correct argument</li>
  <li>Two instances of AcroRd32.exe silently start on the server</li>
  <li>PDF file prints to network printer</li>
  <li>AcroRd32.exe instances end/close </li>
  <li>Batch script completes (which in turn should free up the PHP script)</li>
  <li>PHP script continues and eventually ending to allow end-users to continue with their work</li>
  </ul>
  
  <p><strong>Failed solutions:</strong></p>
  
  <ul>
  <li>Using TASKKILL in the batch file to end AcroRd32.exe processes after print, but AcroRd32.exe remains open, even using the /F (force) flag. When I manually end the AcroRd32.exe processes, the batch file continues and then executes the TASKKILL line, which of course return a "process can't be found" error because it's no longer there. So it would seem the control is not returned back to the batch file after the print, it remains with AcroRd32.exe.</li>
  </ul>
  
  <p>Does anyone have any ideas how I can close Adobe Reader after the PDF prints?</p>