Found a solution [though open for better suggestions]
First needs to check and kill
if php tasks exists
, then command prompt will kill
:
// It will first list out all `php.exe` tasks running
$output = shell_exec('tasklist /svc /fi "imagename eq php.exe"');
print_r($output);
echo "<br> ------------------------------------ <br>";
// It will first list out all `cmd.exe` tasks running
$output = shell_exec('tasklist /svc /fi "imagename eq cmd.exe"');
print_r($output);
echo "<br> ------------------------------------ <br>";
// kills php.exe tasks
$php_output = shell_exec('taskkill /F /IM "php.exe"');
print_r($output);
echo "<br> ------------------------------------ <br>";
// kills cmd.exe tasks
$cmd_output = shell_exec('taskkill /F /IM "cmd.exe"');
print_r($output);
echo "<br> ------------------------------------ <br>";
die(ucfirst('all tasks killed'));
Hope it helps to all !