Jump to content

Featured Replies

Posted

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.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...