I am trying to get windows processes matching some certain criteria, e.g. they are like "123456.exe" and trying to kill them with tasklist. I am trying to do it like that:
FOR /F "usebackq tokens=2 skip=2" %i IN (`tasklist |findstr /r "[0-9].exe") DO taskkill /PID %i
which is not right and I don't know why.... Can anyone give me a hint? Thanx in advance!
If the processes name difference is not very complex, e.g. if the name is always the same you can use the /FI option of taskkill directly
==> taskkill documentation
Several changes:
By the way, if you place this command in a batch script, remember to use "%%i" instead of "%i" for your parameters, or you'll get an error message like
i was unexpected at this time.