C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Your Ad Here


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Process »

Find all running processes in windows and kill the processes


Posted Date: 25 Apr 2007    Resource Type: Code Snippets    Category: Process
Author: Pritam BaldotaMember Level: Gold    
Rating: 1 out of 5Points: 10



You can access all runnig windows processes and kill them using System.Diagnostics.Process class in C# .

See the sample code below which finds all running processes and adds to a listbox. In button click event, the se;ected process is killed by calling Process.Kill() method.

								
//List the Processes
private void Button1_Click(object sender, System.EventArgs e)
{
lstProcess.Items.Clear();
try
{
Process[] myProcc;
myProcc=Process.GetProcesses();
lstProcess.DataSource=myProcc;
lstProcess.DataTextField="ProcessName";
lstProcess.DataValueField="Id";
lstProcess.DataBind();
}
catch(Exception ex)
{ }
}


//Kill Specific Process
private void Button2_Click(object sender, System.EventArgs e)
{
try
{
Process myn = Process.GetProcessById(int.Parse(lstProcess.SelectedValue));
myn.Kill();
}
catch(Exception ex)
{
Response.Write("Err "+ex.Message);
}
Response.Write("Kill "+lstProcess.SelectedValue);
}




Responses to the resource: "Find all running processes in windows and kill the processes"

No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Searching for SSN(Social Security Number) inside Files (pdf,doc,txt,xls , all binary files) using C#
Previous Resource: Retrieve Environment Variables defined in a System
Return to Discussion Resource Index
Post New Resource
Category: Process


Post resources and earn money!
 
More Resources




About Us    Contact Us    Privacy Policy    Terms Of Use