Thank you all for your comments. Unfortunately, this "php start printjob" was part of a larger project that was canceled today due to, well ... I donβt know ... political reasons. Guess that the project is pretty much dead.
In any case, I tried myself several more times in recent days and could not get it to work with IIS. My solution that I implemented and tested already: uninstall IIS, install the XAMPP or WAMPP package with local apache and PHP, which works with administrator access rights.
It did the trick. I used pclose(popen('...command...', 'r')); in PHP to run .exe , and so PHP does not wait for the completion of the PDF file. Everything worked perfectly.
Here is my C # code that runs a print job using Acrobat Reader
public void Print(string pathname, string acrobatDirectory) { var proc = new Process { StartInfo = { Arguments = String.Format("/t \"{0}\"", pathname), FileName = acrobatDirectory, UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = false, RedirectStandardError = false, } }; proc.Start(); }
The first argument is the path to the PDF to be printed, the second parameter is the absolute path to AcroRd32.exe .
The only problem was that AcroRd32.exe was started, printed, and was not closed again. Therefore, each printjob started a new instance of AcroRd32.exe (I use Acrobat Reader 9.0). Therefore, if you printed 10 times, 10 copies of the acrobat reader were created.
I started to run the print job, and then waited X seconds, hoping the printer was finished, and then killed all instances of AcroRd32.exe :
public void Print(string pathname, string acrobatDirectory) { Debug.WriteLine("Printing..."); Printer.Print(pathname, acrobatDirectory); Thread.Sleep(30000); try { Debug.WriteLine("Trying to kill runnung AcroRd32.exe "); FindAndKillProcess("AcroRd32"); } catch (Exception) { Debug.WriteLine("AcroRd32.exe could not be killed..."); } } private bool FindAndKillProcess(string name) { foreach (Process clsProcess in Process.GetProcesses()) { if (clsProcess.ProcessName.StartsWith(name)) { clsProcess.Kill(); return true; } } return false; }
It worked out quite well.
Please note that the above (killing all AcroRd32.exe and running PHP with administrator privileges) was only possible because: All this is used by only one user at a time and has a very limited scope .
It should be used in a touch-screen application deployed on a client PIC. The seller must use the PHP application to configure the product, and then PHP will call my .exe, which would create and print the PDF in the background. The printed document is then transmitted to the client. Therefore, security, etc. in this case was not a problem.
If anyone has a solution to use it with IIS, I still agree to accept it as an answer.