Detect if a process is running then start it if notTag(s): Misc Prog HowTo
About cookies on this site
We use cookies to collect and analyze information on site performance and usage,
to provide social media features and to enhance and customize content and advertisements.
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
REM adapt the list below to match your need
SET EXE=(notepad.exe wordpad.exe outlook.exe)
FOR %%i IN %EXE% DO (
TASKLIST /NH /FI "IMAGENAME EQ %%i" 2>NUL | FIND /I /N "%%i">NUL
IF !ERRORLEVEL! EQU 0 ( CALL :ProcessFound %%i ) ELSE ( CALL :ProcessNotFound %%i )
)
ECHO Done.
EXIT /B 0
:ProcessFound
ECHO %1 is running
EXIT /B 0
:ProcessNotFound
ECHO %1 is not running
REM uncomment the line below to start a not-found process
REM START %1
EXIT /B 1