Forum How do I...?

CreateProcess Failed

ghazuria
I am using Prince XML for the first time and can't seem to get it working. When I try to run it using the php class (using the GUI I have no problems), it gives me the following error.

Warning: proc_open() [function.proc-open]: CreateProcess failed in C:\Web\pdf\prince.php on line 242

Fatal error: Uncaught exception 'Exception' with message 'Failed to execute c:\PrincePDF\Engine\bin\prince.exe --server "c:\web\pdf\test.html" "c:\web\pdf\generated.pdf"' in C:\Web\pdf\prince.php:258 Stack trace: #0 C:\Web\pdf\prince.php(177): Prince->convert_internal1('c:\PrincePDF\En...', Array) #1 C:\Web\pdf\test.php(5): Prince->convert2('c:\web\pdf\tes...', 'c:\web\pdf\gen...') #2 {main} thrown in C:\Web\pdf\prince.php on line 258

The php file used to call it contains the following:
require_once('prince.php');

$pdf = new Prince('c:\\PrincePDF\\Engine\\bin\\prince.exe');
$pdf->convert2('c:\\web\\pdf\\test.html','c:\\web\\pdf\\generated.pdf');



The HTML file is very simple:
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<table>
<tr>
<td>Test</td>
<td>
<table>
<tr>
<td></td>
<td>Test 2</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>This is a really long test</td>
</tr>
</table>
</body>
</html>


I thought this might be a problem with permissions on the directory where prince is located but I have it set so that the internet user account for IIS has full control and I still get this error.

Any help would be appreciated.


Thanks.
mikeday
Are you running PHP in safe mode or any other mode that might disable the proc_open call? Is the path c:\PrincePDF\Engine\bin\prince.exe correct? Can you try calling proc_open directly from your PHP page and use it to run Prince with no arguments, or run another simple program, to see if the CreateProcess still fails?
ghazuria
Thanks for the quick reply.

I checked the php.ini settings, safe_mode was off and there were no functions listed in the disable_functions setting.

I tried using proc_open.
$des = array(
   0 => array("pipe", "r"), 
   1 => array("pipe", "w"), 
   2 => array("file", "C:\\PrincePDF\\Engine\\bin\\error-output.txt", "a") 
);
$res = proc_open('C:\\PrincePDF\\Engine\\bin\\prince.exe',$des,$pipes);

It gave me the same error. CreateProcess Failed. However, it did create the error-output.txt file (with nothing inside) so it does have access to that directory.
I also tried it with a simple .bat file and the same error. It is that function that is failing and not prince.exe but I don't know why.
ghazuria
I found the answer to the problem.
http://readlist.com/lists/lists.php.net/php-windows/0/798.html

It was a permission problem but not in the prince folder, for cmd.exe

If using IIS6 in windows 2003 server, you have to grant IIS user read and execute permissions to cmd.exe

Thanks for your help.
mikeday
Great, thanks for posting the solution! :)