Running and terminating an exe file with PHP

Hello,

I need to build a web page where I can remotely run and terminate a .exe file.

I will basically build a start and stop button but I am not sure how to go about actually running and terminating the program.

Any help would be greatly appreciated.

Thank you.

I’ve got the page working to start the exe. using the following:

<form method="post"><input type="submit" name="submit" value="Start Game Server"> | <input type="submit" name="submit" value="Start Master Server"></form>

<?php
if($_POST['submit'] == "Start Game Server")
{
	exec("E:\\GameServer\\Server.exe");
	echo "Game server has been started";
}else
{
	exec("E:\\MasterServer\\MasterServer.exe");
	echo "Master Server has been started";
}	

?>

Does anyone know how to check to see if it’s already running? can i use

proc_get_status();

and to terminate?

Can i use:

proc_terminate();

I’m not very familiar with the windows command line. But if you plan to start a process from php, you’ll need to do it in a way that lets the php script exit before the process finishes. Maybe try searching php background process windows to see what the commands would be.

I just played with it real quick and this seems to work to see if a process is running
tasklist /fi “imagename eq apache.exe”

And to kill
taskkill /im apache.exe

Thanks malibu I will try that. Not finding much info out there.