Jump to content
thedexmonster

Simple program to kill a program

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×