Using information from the answer below, I tried
set curlsnum=tasklist /FI "IMAGENAME eq curl.exe" 2>NUL | find /I /C "curl.exe"
echo %curlsnum%
and this returns
set curlsnum=tasklist /FI "IMAGENAME eq curl.exe" 2>NUL | find /I /C "curl.exe"
0
echo
ECHO is on.
So it counts it properly, but for some reason the zero doesn't make it into the variable. Set /a doesn't make any difference either. I must be missing something obvious but can't work out what. Do variables have to be natural numbers or something weird?!
How to count amount of processes with identical name currently running, using a batchfile
echo %curlsnum%I bet it's not what you expect. Get output of command to a variableset curlsnum=tasklist /FI "IMAGENAME eq curl.exe" 2>NUL? So, how manycurl.execould you expect?for /F %%I in ('%SystemRoot%\System32\tasklist.exe /FI "IMAGENAME eq curl.exe" /NH ^| %SystemRoot%\System32\find.exe /C "curl.exe"') do set "curlsnum=%%I"to get the number of runningcurl.exetasks output byfindassigned to an environment variable with namecurlsnum. Run in a command prompt windowfor /?andtasklist /?andfind /?andset /?for the usage helps of the four Windows commands used here.