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