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

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...