Home > DeveloperSection > Articles > Check Running Process in CSharp .NET

Check Running Process in CSharp .NET

C# C# 
0 Comment(s)
 4852  View(s)
Rate this:


Process Check application shows the currently running processes. You can also end running process.

Form Details

Objects name


Select list box:     lstProcess

Process currently running list box: lstAll

Check button:   btnCheck

End Process button: btnKill

Check All button: btnCheckAll

Exit button: btnExit

Form code with Explanation


//Code for btnExit click event.

      private void btnExit_Click(object sender, EventArgs e)


//Close Application




//Code for btnCheck click event. This will check for the selected process in the select list box(lstProcess)

        private void btnCheck_Click(object sender, EventArgs e)


            Boolean found = false; //store the status for record found or not

            string selItem = Convert.ToString(lstProcess.SelectedItem);//storing the selected item from the list box in selItem

            selItem = selItem.ToUpper();

//converting value of selItem toupper case.

System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();

//assigning running  process in array

// loop to check all running process

            for (int i = 0; i < myProcesses.Length; i++)


//checking whether selected process is running or not. If running then value of found will be assigned //‘true’            

                if (selItem == myProcesses[i].ProcessName.ToUpper())

                    found = true;


            if (found)

                MessageBox.Show(selItem + " is running !!!");


                MessageBox.Show(selItem + " is not running !!!");




//code for button btnCheckAll. This will show all the running processes

//in list box ‘lstAll’

        private void btnCheckAll_Click(object sender, EventArgs e)


            lstAll.Items.Clear(); //this will clear the list box.

System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();     

//fetching all running processes and storing in myProcess array.

//loop for adding all running process in list box.

            for (int i = 0; i < myProcesses.Length; i++)


slblProcess.Text = "No. of Processes running: "+myProcesses.Length;      //displaying no. of running processes in status bar.

            btnKill.Enabled = true;

            lstAll.SetSelected(0, true);



        private void frmProcess_Load(object sender, EventArgs e)



            lstProcess.SetSelected(0, true);




//code for btnKill click event.

        private void btnKill_Click(object sender, EventArgs e)


            string selItem = Convert.ToString(lstAll.SelectedItem);

            string process;           

            selItem = selItem.ToUpper();

System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();

//loop to check for running process selecter from lstAll list box.

            for (int i = 0; i < myProcesses.Length; i++)


                process = myProcesses[i].ProcessName;

                process = process.ToUpper();



                    if (selItem == process)


//killing process selected from lstAll list box


                catch (Exception ex)








Screen shots

Don't want to miss updates? Please click the below button!

Follow MindStick