Find Other Running Processes

Problem

You want to retrieve information about processes that are currently running.

Solution

Use the GetProcesses or GetProcessesByName methods of the System.Diagnostics.Process class.

Discussion

The System.Diagnostics.Process class represents a Windows process. It provides an exhaustive list of properties, which are detailed on MSDN. Using this information, you can

  • Examine an application’s memory, thread, and CPU usage.

  • Determine when an application started and how long it has been executing.

  • Retrieve information from the executable file that was used to launch the application.

You can also use the Process class methods to end a process (as described in recipe Terminate Another Process), and you can handle the Process.Exited ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.