Counting process instances using Batch <p>Im trying to count the number of php-cgi.exe processes on my server 2003 system using "tasklist" and grep <a href="http://gnuwin32.sourceforge.net/packages/grep.htm" rel="nofollow">for windows</a>. I would like to avoid writing to any temp files.</p> <pre><code>call set _proc_cnt = tasklist /fi "Imagename eq php-cgi.exe" /nh /fo CSV| grep -c -e "php-cgi" echo %_proc_cnt% pause </code></pre> <p>Heres what I get when I run that</p> <pre><code>C:\Users\gm\Desktop&gt;call set _proc_cnt = tasklist /fi "Imagename eq php-cgi.exe" /nh /fo CSV | grep -c -e "php-cgi" 0 C:\Users\gm\Desktop&gt;echo ECHO is on. C:\Users\gm\Desktop&gt;pause Press any key to continue . . . </code></pre> <p>Does anyone have any tips on why that doesnt work?</p>