WMCI - how to get the ERRORLEVEL
I want to use the "wmic" command for finding out if a specific java process is still up and running.
E.g.> wmic process where "commandLine like '%ACTMonitor%' and executablePath like '%PATH1%' and name like '%java%'"
The problem now is that the errorlevel of this command is always 0, no matter if there is a process listed or not. How can I manage to get an errorlevel != 0 in case the process is not up anymore? Or can one of you tell me another suggestion o开发者_如何学Cn how to be able to continue in a .bat script with this information...
Thanks in advance!
In general, in a batch file, you can use the FIND
command to check whether you get specific output from a command:
>ECHO This is correct | FIND "correct" > NUL
>ECHO %ERRORLEVEL%
0
>ECHO This is bad | FIND "correct" > NUL
1
Does that help?
精彩评论