note 86438 deleted from function.exec by cmb
| From: | cmb@php.net | Date: | Sun, 24 Nov 2019 08:54:00 +0000 |
| Subject: | note 86438 deleted from function.exec by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213213@lists.php.net to get a copy of this message | ||
Note Submitter: sbourazanis at hotmail dot com
----
Problem:
PHP's System program execution functions do not seem to execute Win32 GUI applications.
Solution:
1.Give %system32%\cmd.exe read/execute permissions to IUSR account.
Why ?:
Delimits the unable to fork errors.
2.Make your web server's executable to interact with desktop and restart it.
Why ?:
If not you cannot see the GUI
3a.Use SysInternals Psexec with -i -d switches:
<?php
exec("Psexec.exe -i -d yourexe.exe");
?>
or
3b.Use Windows scripting shell COM object with false parameter to its Run Function:
<?php
function _exec($cmd)
{
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($cmd, 0,false);
echo $cmd;
return $oExec == 0 ? true : false;
}_exec("youexe.exe");
?>
Why ?:
If you use just exec then PHP waits for exe to terminate, but psexec with -d option or
WshShell->Run with false option overpass this limitation and do not wait for process termination.
I hope this will help all from months' headaches...