Kill process by Title name (not process name).

Posted on 2004-10-31
Last Modified: 2008-01-09
Hi, i'm making a program that terminates other processes by there window title. I'm having dificulties getting a process list and then getting the titles of them all.
Note: I dont need the process name, cuz its not certain that it will always be the same.

The general idea of the program is, it looks through the procsess list and then checks a MySQL database to se if theres any rows there teling the program to kill anyone of thees processes. The rows contain the title name, cuz thay usaly never change when it comes to games and sutch.
I got the SQL part done and its working really good together with ODBC, but i havent figured the process thing out yet, and im having a hard time doing it.

If any one got a better idea on how to kill a special program/process, be free to tell me.
Question by:ellis-
    LVL 2

    Accepted Solution

       I found something that may be usefull to you.

       You need to bind an extisting process and then kill it. Here is a little code

    using System.Diagnostics;

    To kill a process by process name:

    Process[] myProcesses;
    myProcesses = Process.GetProcessesByName("Notepad");

    To kill a process by MainWindowsTitle name:
    Process[] myProcesses;
    myProcesses = Process.GetProcesses();
    foreach(Process p in myProcesses)
         string Name = p.MainWindowTitle.ToLower();
        if(Name.IndexOf("title") != -1)

    I hope this helps you.
    LVL 1

    Author Comment

    changed p.CloseMainWindow(); to p.Kill(); so it really closed it without warning.

    Else, it works like a charm.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Learn The Basics of Ethical Hacking & Pen Testing

    Computer and network security is one of the fastest growing and most essential industries in technology, meaning companies will pay big bucks for ethical hackers. This is the perfect course to leap into this lucrative career, learning how to use ethical hacking to reveal ...

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now