Share via


How to: View Running Processes

When working with processes on a system, it is sometimes necessary to view all processes that are running at a given time. For example, if you want to create an application that gives you the functionality of stopping processes, you must first see which processes are running. You could fill a list box with the process names and select which process to perform any other actions on.

To view running processes

  1. Declare an empty array of the type Process.

  2. Fill the empty array with the return value from the GetProcesses method.

  3. Iterate through the process array using the indexed value to obtain the process name of each process in the array and write it to a console.

    The following example shows how to call the GetProcesses method of a Process component to return the process array and write the ProcessName value to a console.

    Dim myProcesses() As Process
    Dim myProcess As Process
    myProcesses = Process.GetProcesses()
    ' Iterate through the process array. 
    For Each myProcess In myProcesses
        Console.WriteLine(myProcess.ProcessName)
    Next
    
         Process[] myProcesses = Process.GetProcesses();
            foreach (Process myProcess in myProcesses)
            {
                Console.WriteLine(myProcess.ProcessName);
            }
    

See Also

Tasks

How to: Bind to Existing Processes

How to: Stop Processes

How to: Specify Processes

Other Resources

Managing Processes