C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Find all running processes in windows and kill the processes


Posted Date: 25 Apr 2007    Resource Type: Code Snippets    Category: Process

Posted By: Pritam Baldota       Member Level: Gold
Rating:     Points: 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


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

Feedbacks      
Popular Tags   What are tags ?   Search 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!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use