How To End Process Using C#

end process

This is a very nice tutorial and very useful in the same time and i am not going to make it so hard since you should learn the basics first ok now you need to create a new project and name the project and after creating the project you should set up the normal things you do and after that i am using a button and a text box so just go ahead and add a button and text box and change the text property of button to "end process" or whatever now when you put the process name in the text box and press the button that process will be ended .

here is the codes

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

//Author : Mohamed Shimran
//Blog : Http://www.ultimateprogrammingtutorials.blogspot.com

namespace EndProcess
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        private void button1_Click(object sender, EventArgs e)
        {

            Process[] ps = Process.GetProcesses();
            foreach (Process p in ps)
            {
                if (p.ProcessName.ToLower() == textBox1.Text )
                {
                    p.Kill();
                }

            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        
    }
}


enjoy and try to make it more stable since its not stable

Post a Comment

Note: Only a member of this blog may post a comment.