Batch: Check if exe is running before executing code

@echo off 

tasklist /FI "IMAGENAME eq program.exe" | findstr "program.exe" >nul 
if %ERRORLEVEL% == 1 goto mycode 
goto eof 
:mycode rem put your code here 
:eof 
exit