Free Information Technology Magazines and eBooks

Thursday, July 02, 2009

VB.NET: How to list all running process in Windows

On my Computer Monitoring Tool blog post, I already explained how to retrieve windows processes but in C#. On this post, I will show you how to list current running windows process using VB.NET. The code will use of System.Diagnostics namespace to explore the Process class which will give us the access to information of running processes.


Of course, What we need first is to include the most important namespace.


Imports System.Diagnostics


Now to show the list of all running process in windows, use the following codes.


Dim psList() As Process
Try
psList = Process.GetProcesses()

For Each p As Process In psList
Console.WriteLine(p.Id.ToString() + " " + p.ProcessName)
Next p

Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Console.ReadKey()


The result should look like this.

How to list all running process in Windows using VB.NET

You can download the complete sample Visual Studio 2008 project here.

For more coding tips & tricks, subscribe now.

0 comments: