al********@gmail.com wrote:
Hi All,
I need to get all the IDs of specific process and kill all the
instances of that process.
Something like:
// theArray get all the Excel proc IDs in the Task manager
string[] theArray = new string[100];
//there can be more then one instance of excel in Task manager
theArray = GetAllProcessID("Excel");
for (int i = 1; i 100; i++)
killProcessbyID(theArray[i]);
Thanks for the help.
NM,
Just found the solution. atleast I learned something. Always google
before you post a new post :(.
Comments are wellcome.
private void button1_Click(object sender, System.EventArgs e)
{
string a = "";
Process[] procList = Process.GetProcesses();
for ( int i=0; i<procList.Length; i++)
{
if(procList[i].ProcessName.ToString() == "EXCEL")
{
a+= "Process ID="+procList[i].Id +"\t"+"Process
Name="+procList[i].ProcessName+"\n";
procList[i].Kill();
}
}
MessageBox.Show(a);
}