作为我无法启动 SRCDS(Source 游戏引擎的专用服务器)故障排除的一部分,我决定尝试启动其他一些可执行文件(特别是 Chrome 和 Firefox)。然而,这些都没有推出。页面已加载(没有像 SRCDS 那样挂起),但在检查 Windows 任务管理器时,这些进程从未真正启动。$output 是一个长度为 0 的数组, $return_var 是 1 (没有给我关于发生的实际错误的信息。
我使用的代码是(使用system
orpassthru
代替时没有变化exec
):
<?php
// Save the current working directory, then set it to SRCDS' directory
$old_path = getcwd();
chdir("C:/Users/Johan/Desktop/SteamCMD/tf2/");
// Launch SRCDS. Only the 3rd exec allows the page to load.
//$tmp = exec("srcds -console -game tf +map ctf_2fort 2>&1",$output,$output2);
//$tmp = exec("srcds -console -game tf +map ctf_2fort >> tmp.txt",$output,$output2);
$tmp = exec("srcds -console -game tf +map ctf_2fort 1>/dev/null/ 2/&1",$output,$output2);
echo "<p>SRCDS Output: ".sizeof($output)."</p>";
echo "<p>SRCDS Output2: ".$output2."</p>";
// Test execution of other files
// test.bat echoes %time%
$tmp2 = exec("test.bat");
echo $tmp2;
// Trying to launch another executable
chdir("C:\Program Files (x86)\Mozilla Firefox");
$tmp2 = exec("firefox", $output, $output2);
echo $tmp2;
echo "<p>FF Output:".sizeof($output)."</p>";
echo "<p>FF Output2:".$output2."</p>";
// End
chdir($old_path);
echo "Done.";
?>
这输出:
SRCDS Output: 0
SRCDS Output2: 1
0:47:59,79
FF Output:0
FF Output2:1
Done.
我的问题是,这有什么理由吗?我做错了吗?