Kill process by Title name (not process name).

Posted on 2004-10-31
Medium Priority
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-

Accepted Solution

dsabo earned 500 total points
ID: 12457713
   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.

Author Comment

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

Else, it works like a charm.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses
Course of the Month5 days, 18 hours left to enroll

589 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