To Kill a process

Sakthi.Singaravel
Posted by Sakthi.Singaravel under C# category on | Points: 40 | Views : 1071
In button event to kill a word process, code as follows..

private void button3_Click(object sender, EventArgs e)
{
Process[] ExistingProcess = null;
Process ChkProcess = null;
ExistingProcess = Process.GetProcessesByName("winword");
foreach (Process ChkProcess_loopVariable in ExistingProcess)
{
ChkProcess = ChkProcess_loopVariable;
if ((ChkProcess.ProcessName) == "WINWORD")
{
ChkProcess.Kill();
MessageBox.Show ( "Deleted");
}
}
}

Comments or Responses

Login to post response