Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>You can use Windows Management Instrumentation:</h2> <p>If you have not used <code>wmic</code> before you should install it by running <code>wmic</code> from <code>cmd.exe</code>. It should then say something like:</p> <pre><code>WMIC Installing... please wait. </code></pre> <p>After that <code>wmic</code> is ready for use: </p> <pre><code>function getProcessId( $imagename ) { ob_start(); passthru('wmic process where (name="'.$imagename.'") get ProcessId'); $wmic_output = ob_get_contents(); ob_end_clean(); // Remove everything but numbers and commas between numbers from output: $wmic_output = preg_replace( array('/[^0-9\n]*/','/[^0-9]+\n|\n$/','/\n/'), array('','',','), $wmic_output ); if ($wmic_output != '') { // WMIC returned valid PId, should be safe to convert to int: $wmic_output = explode(',', $pids); foreach ($wmic_output as $k =&gt; $v) { $wmic_output[$k] = (int)$v; } return $wmic_output; } else { // WMIC did not return valid PId return false; } } // Find out process id's: if ($pids = getProcessId( "chrome.exe" )) { foreach ($pids as $pid) { echo "Chrome.exe is running with pid $pid"; } } else { echo "Chrone.exe is not running"; } </code></pre> <p>I have not tested this and just wrote it out of my head so there might be some fixing and you should check wmic's output by running it from commandline with same args to see if <code>preg_replace()</code> is doing it right (get pid from wmic's output).</p> <h3>UPDATE:</h3> <p>Tested and it seems that <code>wmic</code> does not return any status codes so updated my php function to reflect this bahavior.</p> <h3>UPDATE:</h3> <p>Now it handles multiple processes too and returns all pids as indexed array or false when no process running.</p> <h3>About WMI:</h3> <p>Windows Management Instrumentation is very powerful interface and so is <code>wmic</code> commandline tool. <a href="http://en.wikipedia.org/wiki/Windows_Management_Instrumentation#Features" rel="nofollow">Here is listed some of WMI features</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload