如何使用PHP启动Windows GUI程序?

lin*_*ing -1 php firefox firefox-addon

可能重复:
php如何启动运行的外部程序-系统和exec出现问题

如何用php打开exe?
我有了这个主意,并努力使它成功了好几年了,但是最后还是失败了。有人告诉我完成这项工作的成功方法吗?

<?php 
    if(isset($_POST['file_path'])){
        /* ------- 
            using "notepad++.exe" to open "test.php" file.
            or run a bat file which calling "notepad++.exe" to open "test.php" file.
            how to seting php.ini or firefox or any setting to do this job. 
            it is only for conveniently developing web page in my PC ,not for web servers
        ------- */
    }
?>

<form action="test.php" method="post">
    <input type="text" name="file_path" value="test.php"/>
    <button type="submit">open with notepad++</button>
</form>
Run Code Online (Sandbox Code Playgroud)

这将创建如下内容:

渲染的HTML屏幕截图

goa*_*oat 5

要在运行Web服务器的计算机上启动程序,请执行以下操作:

<?php
exec('"C:\Program Files (x86)\Notepad++\notepad++.exe" "C:\foo.php"');
Run Code Online (Sandbox Code Playgroud)

如果Web服务器未作为Windows服务运行,则以上内容将在vista / win7上运行。例如,如果您运行apache并且它在计算机启动时自动启动,则可能是将其安装为服务。您可以检查apache是​​否在Windows服务选项卡中显示。

如果网络服务器作为服务运行,则需要研究为该服务启用“允许桌面交互”选项。然而在其他方面:

使用php的新内置web服务器(php 5.4+)进行的简单测试。这里的关键是您从Shell手动启动服务器,因此它以您的用户身份而不是服务身份运行。

<?php
// C:\my\htdocs\script.php
exec('"C:\Program Files (x86)\Notepad++\notepad++.exe" "C:\foo.php"');
Run Code Online (Sandbox Code Playgroud)

通过命令窗口启动Web服务器

C:\path\to\php.exe -S localhost:8000 -t C:\my\htdocs
Run Code Online (Sandbox Code Playgroud)

然后在您的浏览器中 http://localhost:8000/script.php