[Bat] 如何確認執行緒存在

這邊提供個批次檔範例, 確認該程式是否有被執行.

tasklist /FI "IMAGENAME eq java.exe" 2>NUL | find /I /N "java.exe">NUL 
if "%ERRORLEVEL%"=="0" (echo Programm is running) else (echo No this Program)

若執行緒中有java.exe

就會輸出 
Programm is running

否則輸出
No this Program