PHP执行程序(';program.exe';)挂起网页


PHP exec('program.exe') hangs webpage

正如标题所说,我根本无法通过exec()让我的PHP代码在服务器上启动程序。

像这样的简单命令可以很好地工作:

php.exe -r exec('mspaint.exe');

但如果我从这样的网页上尝试,它就会挂起:

<?php
 if (isset($_POST['test'])) {
    exec('C:'Windows'System32'mspaint.exe 2>&1', $output);
    print_r($output);
}
?>
<html>
    <body>
        <form method="post">
        <input name="test" type="submit" value="test!" />
        </form>
    </body>
</html>

我只能在echo等其他命令上获得错误或输出,但尝试启动.exe会挂起网页。我确实注意到mspaint.exe的进程显示在任务管理器中,但窗口本身从未弹出。

如有任何帮助,我们将不胜感激。

您可以使用以下代码:

系统("*:/***.exe");

$result=直通('dir');打印$result;

进一步阅读开放http://php.net/manual/en/function.passthru.php