Run batch file on my webserver using php

I host game servers and I am looking for a way to control a game server through a php page. My game server is started using a batch file and is stopped by closing the process.

Basically, I’m trying to create a button that will start the server and a button that will stop the server. I’d also like to keep it secure as well.

So far the best thing I’ve come up with is this:
[php]<?php
if(isset($_POST[‘submit’]))
{
exec(‘runme.bat’);
} else {
// display the form
?>

<?php } ?>[/php]

This starts the batch file but the webpage is in a state of constantly waiting for host until I close the process.

Keep in mind I’m fairly new to php.

Thanks

ok you are on windows ?

Hello,

As a fellow game server host provider, I have dabbled in the “Watchdog” program created by a batch file. In your case, after you exec the batch file, you can have the page redirect to the page that has the stop button. I’m not sure how you would go about stopping the batch file (I’m sure there is a Window’s command to terminate a process that you can use in the exec() command. Then the page will redirect back to the start button.

I know you may not want to do this, but there are applications out there that manage game servers. Applications like TCAdmin and such dedicate their time to perfecting the controlling of game servers. You may have to pay a little bit, but that’ll give you full control over your game servers.

Hope this helps!

This can be expanded on but something like this:

[php]<?php
if ($_GET[‘start’] == 0){

//Stop code here
echo “Server Stopped”;
die;

} elseif ($_GET[‘start’] == 1){

exec(‘runme.bat’);
header(“location:yourpagename.php?start=0”);

} else {

?>

Start Server

<?php } ?>

[/php]

what does your bat file have in it

“Expansion\beta\arma2oaserver.exe” -port=2316 “-config=BlissRMod\config_7e23489a.cfg” “-cfg=BlissRMod\basic.cfg” “-profiles=BlissRMod” -name=BlissRMod “-mod=@DayZ;@Bliss;@rMod;” -cpuCount=2 -maxMem=1578

Thats the only thing in my batch file at the moment but i will probably expand on it

Basically I want a Page with a Start Button and a Stop Button(And maybe restart) that will start a exe file and it will continue to run until someone hits the Stop Button.

I am able to start the server using:
[php]echo exec(‘server_rmod.bat’);[/php]

but stopping it is proving to be more difficult. Also note that I will have multiple servers running on this machine so there will be multiple exe files called the same thing(arma2oaserver.exe) so i can’t end it simply by killing the process called that.

Sponsor our Newsletter | Privacy Policy | Terms of Service