0

I'm doing an administration for my server and I want to make it remotelly but I found a problem. When I'm starting minecraft server, the process of that file is still working and my page is going to be frozen till that process is killed.

I found many of answers but unfortunately, I'm running it on Windows.

Is it possible? I know that I can start the .bat server which start server, but I want to make it clear.

My code:

chdir("D:/xampp/htdocs/hosting/servers/" . $id);
                //$WshShell = new COM("WScript.Shell");
                //$oExec = $WshShell->Run("ava -Xmx1g -jar minecraft_server.jar", 0, false);
//idk how WshShell works, but it didn't worked..
                exec("java -Xmx1g -jar minecraft_server.jar");

Thank you in advance for your reply!

EDIT

Well, got one problem. I've tried to start something else with WinShell but nothing happend. Nothing is happening when I want to start with WinShell so do I have to enable something to enable WinShell or do anybody know why my WinShell running nothing?

Code

chdir("D:/xampp/htdocs/hosting/servers/" . $id);
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("java -Xmx1g -jar minecraft_server.jar", 0, false);
Junek
  • 15
  • 8

2 Answers2

0

It sounds like you want to trigger the Minecraft server as a background process. While I haven't been able to try the solution below myself, this thread sounds like it's trying to solve a similar problem:

PHP exec() as Background Process (Windows Wampserver Environment)

nsprenkle
  • 191
  • 11
  • Yea, but as I told I was trying it. chdir("D:/xampp/htdocs/hosting/servers/" . $id); $WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run("java -Xmx1G -jar minecraft_server.jar", 0, false); – Junek Jan 17 '18 at 13:48
  • Unfortunately, it do anything even if I am starting some exe files. Do I have to enable something? I am using xampp. – Junek Jan 17 '18 at 13:49
0

Okay, I have solution. Even Wscript.Shell won't work, this command is working.

$cmd = "java -jar D:/xampp/htdocs/hosting/servers/" . $id . "/minecraft_server.jar";
pclose(popen("CMD /C start /B " . $cmd, "r"));

Thank you for trying to help!

Junek
  • 15
  • 8