PHP-有机会通过exec()运行GUI程序吗? [英] PHP - Any chance to run GUI program through exec()?
问题描述
我需要使用exec运行网络浏览器(chrome-firefox ..)
i need to run a web browser (chrome - firefox ..) using exec
i have tried to do it using bat file (this method mentioned here)
C:\Users\farok\AppData\Local\Google\Chrome\Application\chrome.exe www.google.com
当我使用Windows打开文件时,一切正常,但是当我使用exec打开文件时,什么也没发生
when i open the file using windows every thing goes well but nothing happened when i open it using exec
并且我已经尝试通过 BrowserControl 课
BrowserControl.displayURL("www.google.com");
和bat文件一样发生了,所以有什么办法吗?
and the same as bat file happened so is there any way to do it?
注意:我使用wamp 2.2,Apache 2.0,PHP V5.3.8
note:im using wamp 2.2 ,Apache 2.0 , PHP V5.3.8
更新
我发现运行此命令后
exec('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "www.google.com" 2> errors.txt');
firefox在任务管理器中打开,但浏览器界面不可见..有什么想法吗?
firefox dose open in task manager but the browser interface not visible .. any ideas?
推荐答案
我不是Windows专家,但是我认为您需要允许desktop interaction
,如果父进程作为Windows运行,这不容易/不可能.服务. php在apache进程中运行,您可能已经将其作为服务运行.
I'm no windows expert, but I think you need to allow desktop interaction
, which isn't easy/possible if the parent process runs as a windows service. php runs inside the apache process, which you probably have running as a service.
尝试停止服务并手动启动httpd.exe ,然后当我通过apache通过本地主机url请求脚本时,以下内容在win7上对我有用.我的php通过普通的旧cgi与apache交互.
Try stopping the service and manually starting httpd.exe, and then the following works for me on win7 when i request the script via localhost url through apache. my php interfaces with apache via plain old cgi.
exec('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "http://stackoverflow.com/"');
请注意我对引号的使用.
note my use of quotes.
这篇关于PHP-有机会通过exec()运行GUI程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!