@if not defined _echo @echo off setlocal EnableDelayedExpansion :: Check if VBCSCompiler.exe is running tasklist /fi "imagename eq VBCSCompiler.exe" |find ":" > nul :: Compiler is running if errorlevel == 1 if errorlevel 1 ( echo Stop VBCSCompiler.exe execution. for /f "tokens=2 delims=," %%F in ('tasklist /nh /fi "imagename eq VBCSCompiler.exe" /fo csv') do taskkill /f /PID %%~F )