For example, to kill all java processes in background, I found two ways to do it by batch script. One is using PID, and the other one is not. What's the differences between these two methods, and what's the advantage using PID?
Without PID:
taskkill /F /IM java.exe
With PID:
FOR /F "usebackq tokens=2 skip=2" %%i IN (`TASKLIST /FI "IMAGENAME eq java.exe"`) DO taskkill /F /PID %%i