thedexmonster Posted January 26, 2018 Share Posted January 26, 2018 Can someone help me with a very simple program that can run in the background? I need to kill a task based on a filename whenever it starts. I am running Windows 10 x64 if it matters. Quote Link to comment Share on other sites More sharing options...
mooms Posted January 26, 2018 Share Posted January 26, 2018 Here is a loop that will check every 5 seconds if a executable is running, then kill it if found: :loop set "name=the name of your executable" tasklist /FI "IMAGENAME eq %name%" 2>NUL | find /I /N "%name%">NUL if "%ERRORLEVEL%"=="0" ( taskkill /IM %name% /f TIMEOUT 5 goto :loop You cand adjust the time. You can also use PsKill instead of taskkill: https://docs.microsoft.com/en-us/sysinternals/downloads/pskill Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.