Is it possible in Php to check wether an executable is running or not,
some Pseudocode:
if (processExists("notepad.exe")) {
echo "exists";
} else {
echo "doesn't exist";
}
You would only be able to check server-side processes, where PHP is running. JavaScript (client-side) isn't allowed that kind of access because of security.
I understand you are using cli or want to check server-side processes.
For a Windows-specific solution, you can execute the shell command tasklist with the proper options (see tasklist /?). On Unix-based, you would use ps.
To execute a shell command under PHP, you can use shell_exec() or exec().
Warning: Do not enter not sanitized user input in these commands.
This an easy way to check if a proccess is running on Windows using PHP:
exec("tasklist 2>NUL", $task_list);
//print_r($task_list);
foreach ($task_list as $task) {
if (strpos($task, 'MSWC.exe') !== false) { echo " MSWC.exe is running "; }
}
For linux you can use:
exec("pgrep lighttpd", $pids);
if(empty($pids)) {
// lighttpd is not running!
}
C++, if you want to accomplish this.shell_exec()is on the server.