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:
Expected behaviour:
Failed solutions:
Does anyone have any ideas how I can close Adobe Reader after the PDF prints?
I found the following quote at http://www.robvanderwoude.com/commandlineswitches.php#Acrobat
Print a PDF file silently:
AcroRd32.exe /N /T PdfFile PrinterName [ PrinterDriver [ PrinterPort ] ]
The last command will open a new Adobe Reader window, print the PDF file and then terminate
its window unless that window happens to be the only Adobe Reader window left: at least one Adobe Reader window will be left open.
That last sentence is bad news.
You could call AcroRD32.exe with both /N and /T options via the START command, and then your batch file can continue on immediately while the print job executes. If you don't mind one instance of the reader remaining open, then you are done.
If you must close the reader, then your batch will have to kill it. But I'm not sure how your batch file can tell when the print job has finished. You could introduce an arbitrary delay using TIMEOUT, but that sounds risky.
I'm a bit confused about the "two instances of AcroRd32.exe" being opened. If that is the way the program works, then it sounds like the /N switch will close 1 of the 2 instances. Your batch could launch the print job via START, delay a couple seconds to give the print job processes time to start, and then use TASKLIST|FINDSTR to monitor the number of AcroRd32.exe processes in a loop. When the count goes from 2 to 1, the print job should be complete and you can kill the remaining process. In theory anyway :)
Good luck.