I have the following code in a batch file that is called by a PHP script using shell_exec()
:
"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
Parameter %1 is the filename that is sent as an argument to the batch file from the PHP script.
Observed behaviour:
- PHP page successfully calls batch file with correct argument
- Two instances of AcroRd32.exe silently start on the server
- PDF file prints to network printer
- AcroRd32.exe instances do not end/close
- Batch file keeps running (until manually ending AcroRd32.exe processes)
- PHP script is left executing, therefore preventing the client machine to do anything further
Expected behaviour:
- PHP page successfully calls batch file with correct argument
- Two instances of AcroRd32.exe silently start on the server
- PDF file prints to network printer
- AcroRd32.exe instances end/close
- Batch script completes (which in turn should free up the PHP script)
- PHP script continues and eventually ending to allow end-users to continue with their work
Failed solutions:
- 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.
Does anyone have any ideas how I can close Adobe Reader after the PDF prints?