note 86438 added to function.exec
| From: | sbourazanis at hotmail dot com | Date: | Sat, 18 Oct 2008 21:49:07 +0000 |
| Subject: | note 86438 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145481@lists.php.net to get a copy of this message | ||
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...
----
Server IP: 85.196.20.153
Probable Submitter: 85.72.154.216
----
Manual Page -- http://www.php.net/manual/en/function.exec.php
Edit -- https://master.php.net/note/edit/86438
Del: integrated -- https://master.php.net/note/delete/86438/integrated
Del: useless -- https://master.php.net/note/delete/86438/useless
Del: bad code -- https://master.php.net/note/delete/86438/bad+code
Del: spam -- https://master.php.net/note/delete/86438/spam
Del: non-english -- https://master.php.net/note/delete/86438/non-english
Del: in docs -- https://master.php.net/note/delete/86438/in+docs
Del: other reasons-- https://master.php.net/note/delete/86438
Reject -- https://master.php.net/note/reject/86438
Search -- https://master.php.net/manage/user-notes.php