如何使用PHP打开一个新的CMD窗口 [英] how to open a new CMD window using PHP
本文介绍了如何使用PHP打开一个新的CMD窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在最近几天,我在PHP中编写代码来弹出 CMD 窗口,而这个 CMD 窗口中有一个命令,例如 ping google.com 并处理它
i不需要PHP代码来读取结果,我只希望它运行
i尝试了一些像
In the last days i was tying to code something in PHP to popup a CMD windows and this CMD windows have a command like "ping google.com" and process it
i don't need the PHP code to read the result , i only want it to run it
i tried some thing like
<?php
exec('C:\Windows\System32/cmd.exe ping google.com');
<?
但没有结果(我不知道它是否在后台运行)
所以我阅读这,我创立了很多方式,但没有工作
but no result (i don't know if it run it in background )
so i read this and i founded many ways but nothing worked
我的操作系统是windows,感谢所有人:)
My OS is windows and thanks alot for all :)
推荐答案
是
i搜索alot找到它:))
the answer is
i searched alot to find it :))
<?
execInBackground('start cmd.exe @cmd /k "ping google.com"');
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
?>
这篇关于如何使用PHP打开一个新的CMD窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文