# Windows Batch Script Automated taskkill



## noisexkillua (Nov 2, 2011)

Hi guys Im currently developing an automated task killer which should delete a process from the tasklist at a time specified, say every 5 minutes. I've got the time algorithm and the code to filter the processes into certain criterias so if they dont fulfil it, the get killed, say the criteria is like if it uses more than 10,000 K memory usage they get killed.

Now is there any other criteria i can use to ensure that the program only kill application processes and not any of the system processes? Any advice would be good, thanks


----------



## Squashman (Apr 14, 2005)

Look at the username in the output of *tasklist /v*


----------



## noisexkillua (Nov 2, 2011)

Sorry my question seemed a bit too vague. I want to filter and kill unnecessary processes that's why i was trying to find out how to criteria each processes. Last time I tried it, it messed up my computer so I want to make sure that it kills only processes that were run by me as an application process and not mess up my computer.


----------



## LMiller7 (Jun 21, 2010)

Sorry, but I find your whole concept seriously flawed. What is the purpose in this? Killing processes that meet some criteria in order to improve performance or solve some problem doesn't seem like a very good approach. However much intelligence you put in the program the time will come when a critical process is killed. Most likely it would be the application you are using at the time.

I have studied processes, applications, services, quite a bit and I have no idea how I would do what you are attempting in a way that was both useful, and safe.


----------



## niemiro (Feb 20, 2010)

LMiller7 said:


> Sorry, but I find your whole concept seriously flawed. What is the purpose in this? Killing processes that meet some criteria in order to improve performance or solve some problem doesn't seem like a very good approach. However much intelligence you put in the program the time will come when a critical process is killed. Most likely it would be the application you are using at the time.
> 
> I have studied processes, applications, services, quite a bit and I have no idea how I would do what you are attempting in a way that was both useful, and safe.


I completely agree with you. The only way I could think of doing this at all safely would be to create a blacklist, but that would be so incomplete as to be useless, still open to interpretation and personal tastes, and not perfectly safe.


----------



## LMiller7 (Jun 21, 2010)

There is an aspect to this I didn't mention and should have. Killing a process from the outside is an inherently risky procedure and should only be done in exceptional circumstances. It is always preferred to ask the process to end itself, such as by clicking the application close button.

Killing a process by any other method essentially pulls the plug on the process without regard for it's internal state or what it may be doing. It is given no opportunity to update files, the registry, or other things it would normally do when the process ends. This can, and over the long term will, lead to data corruption and other problems. There really isn't a way to do this safely. This is not something you want to do on a periodic basis.

Whatever you are trying to accomplish there has to be a better way.


----------



## Ninjaboi (Dec 27, 2010)

A programmer's goal is to accomplish a certain task or answer a question using code. Although code is their weapon, it's not all they can do. A good programmer looks first at other options to see if there is already a way to solve the task they desire done. If not, they then look for if there are resources or material already created that could be morphed or edited to do the task required. If and only if those turn up nothing, then the programmer delves in to get in the mud of the work. Of course, this is saying "Don't re-invent the wheel", which many people do in order to make a better version entirely ( don't confuse with the term 'innovation', as that's an improvement on an already current model or item, which would be the "morph or edit" method ). It's in the best of heart to only create a program like this only if there is no other alternative, due to it being a very delicate operation.

Perhaps you just want to disable programs from running on startup to increase performance?

You can improve your computer's performance by preventing unnecessary programs from running automatically when Windows starts. Here's how:

1. Open Windows Defender by clicking the Start button , clicking All Programs, and then clicking Windows Defender. 
2. Click the Tools button, and then click Software Explorer.
3. In the Category box, click Startup Programs.
4. Select the program that you want to prevent from running, and then click Disable.
5. Click Yes to confirm that you want to stop that program from running.
6. Repeat steps 4 and 5 for every program you want stop from running. 

*Source(s):*

Stop a program from running automatically when Windows starts


----------

