Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c# + getting proccesses 1

Status
Not open for further replies.

kalkalai

Technical User
Feb 24, 2006
33
KZ
Hi,

I am trying to get all the processes running and kill them like this

foreach (Process process in Process.GetProcessesByName("Excel"))
{
process.Kill();
}


But the problem with this is that there may be processes that were not started by my application...

For example, I am running an application written in C# it initiates Excel processes, how can I collect only those Excel processes that were started by my application and kill only those no others!

Thanks in advance!
 
as you start an instance of excel you could add it to list of processes/process names. when the time comes use that list to kill the processes.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
As a note, i would add the Process ID to a list rather than the name - then kill via the PID, just to avoid any more conflicts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top