My solution, because in Windows7 only IF ERRORLEVEL 1does not work, and the error level is 0 if findstrsuccessful or not.
In my case, I'm looking for something launched by java.exe, let's say HELLO.jar [java.exe parameter]
wmic PROCESS LIST FULL | findstr /I java.exe | findstr /I HELLO.jar
if ErrorLevel 1 (
Echo OK
msg "%username%" HELLO.jar not started
Pause
) else (
Echo ERR
msg "%username%" HELLO.jar already running
Pause
exit
)
source
share