I'm trying to write one line cmd command that:
tasklist
with PID filterSo I've read How to extract a specific field from output of tasklist on the windows command line and used this answer to construct this command:
for /f "tokens=2 delims=," %F in ('tasklist /nh /fi "PID eq 5284" /fo csv') do if %F NEQ "5284" (@echo no) else (@echo yes)
I didn't get the expected result. Most likely got the syntax wrong.
Just posting the answer commented by eryksun:
(for /f "tokens=2 delims=," %F in ('tasklist /nh /fo csv /fi "PID eq 5284"') do @echo yes) || @echo no