问题描述
如何用php打开exe文件?
我有这个想法,年,但终于失败了。任何一个告诉我一个成功的方法来做这个工作?
<?php
if(isset($ _ POST ['file_path'])){
/ * -------
使用notepad ++。exe打开test.php文件。
或者运行一个叫notepad ++。exe的bat文件来打开test.php文件。
如何设置php.ini或Firefox或任何设置来完成这项工作。
它只是为了方便地在我的电脑上开发网页,而不是用于web服务器
------- * /
}
?>
< form action =test.phpmethod =post>
< input type =textname =file_pathvalue =test.php/>
< button type =submit>用记事本++打开< /按钮>
< / form>
这会产生类似于:
<?php
exec( 'C:\程序文件(x86)\Notepad ++ \\\
otepad ++。exeC:\foo.php');
如果Web服务器不能作为Windows服务运行,以上将在vista / win7上运行。例如,如果您运行apache,并且在您的计算机启动时自动启动,则可能将其作为服务安装。你可以检查apache是否显示在windows服务标签中。
如果web服务器作为服务运行,你需要考虑启用允许桌面交互选项的服务。但另有:
使用php新建的webserver(php 5.4+)进行简单的测试。这里的关键是你手动启动服务器从一个外壳,所以它作为你的用户而不是作为服务运行。
<?php
// C:\my\htdocs\script.php
exec('C:\ Program Files(x86)\Notepad ++ \\\
otepad ++。exe C:\foo.php');
通过命令窗口启动web服务器
C:\path\to\php.exe -S localhost:8000 -t C:\my\htdocs
然后在浏览器中
http:// localhost:8000 / script.php
how to open exe with php?
I had this idea and make hard to success it for several years,but failed at last. any one tell me a success method to do the job ?
<?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>
This would create something like:
To launch a program on the computer which runs the webserver:
<?php
exec('"C:\Program Files (x86)\Notepad++\notepad++.exe" "C:\foo.php"');
The above will work on vista/win7 IF the webserver does not run as a windows service. For example, if you run apache and it automatically starts when your computer boots, you probably installed it as a service. You can check to see if apache shows up in the windows services tab/thingy.
If the webserver runs as a service, you'll need to look into enabling the "allow desktop interaction" option for the service. But otherwise:
An easy test using php's new built in webserver(php 5.4+). The key thing here is you manually start the server from a shell, so it runs as your user instead of as a service.
<?php
// C:\my\htdocs\script.php
exec('"C:\Program Files (x86)\Notepad++\notepad++.exe" "C:\foo.php"');
start a webserver via a command window
C:\path\to\php.exe -S localhost:8000 -t C:\my\htdocs
Then in your browser http://localhost:8000/script.php
这篇关于我如何使用PHP启动Windows GUI程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!