如何使用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 &");
}
}
?>