The script below will find out if the Selenium Server (java jar file) is already running in windows.  It uses the Windows Management Instrumentation Command-line (wmic) to look at the processes that are running as “java.exe” and gets the command line that started them.  The php script than Iterates through the command line output and looks for  “selenium-server-standalone”.

If you’re not familiar with Selenium you can learn how to use it with PHP here!

exec("wmic process where name=\"java.exe\" get commandline",$output);
foreach($output as $line)
if(strpos($line, $javaProgramFileName) !== FALSE)
//Execute in the background by sending output to NUL
exec("java -jar ".__DIR__."\selenium-server-standalone-2.47.1.jar > NUL");
//Selenium is up an running lets use the PHP Selenium Driver