Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Kill process by Title name (not process name).

Posted on 2004-10-31
2
Medium Priority
?
7,533 Views
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.
0
Comment
Question by:ellis-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
dsabo earned 500 total points
ID: 12457713
Hello,
   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");
myProcesses[0].CloseMainWindow();

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)
        p.CloseMainWindow();
}

I hope this helps you.
0
 
LVL 1

Author Comment

by:ellis-
ID: 12458010
Great!!
changed p.CloseMainWindow(); to p.Kill(); so it really closed it without warning.

Else, it works like a charm.
thx
//ellis
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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