Friday, 28 September 2012

How to determine if a process is running in a DOS batch file

 

Trick is to use tasklist.exe and pipe the output through a find then check the errorlevel as follows...

tasklist /FI "IMAGENAME eq WebDev.WebServer40.exe" 2>NUL | find /I /N "WebDev.WebServer40.exe">NUL
if "%ERRORLEVEL%"=="0" GOTO START
echo. Starting web app dev server
call sw.bat

:START

No comments:

Post a Comment