samedi 11 avril 2015

Closing Opened Program Via PHP

Im trying to find a way to close a program that i have recently opened with PHP. Part of a start and stop server system ( Server made in java with .bat ). I can only get it to open in the background, and yes i have the interact with desktop enabled. I was wondering if there was a way i could return the PID of the proccess of program i initiate at first, then use that pid to close the program at a later time.


PHP PAGE CODE FOR STARTING





<?php
session_start();
$id = $_GET['serverid'];

$mysqli = new mysqli("localhost", "root", "", "mainrspshosts");

/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
$query = "SELECT * FROM servers WHERE id = '" .$id. "' LIMIT 1";

if ($result = $mysqli->query($query)) {

/* fetch associative array */
while ($row = $result->fetch_assoc()) {
if($_SESSION["username"]==$row["owner"]){


set_time_limit(300);


echo "Starting...<br><br>";
$output = shell_exec('c:\WINDOWS\system32\cmd.exe /c START run474.bat');
echo($output);
echo "Success!";
header("refresh:5;url=http://ift.tt/1FvQmMA");











}
else{

header("location:index.php");

}
}
}
else{

header("location:index.php");
}



?>



Aucun commentaire:

Enregistrer un commentaire