July 13, 2002

Write a console utility to list processes

The Process class provides all you need to create a command-line utility that lists all the processes running on the system and all the related information. This utility is therefore

Write a console utility to kill a process

The System.Diagnostics.Process class exposes two methods that let you kill a process: CloseMainWindow should be used with processes that have a graphical interface, whereas the Kill method should be used

Wait for a process to terminate

You can use the VB.NET Shell command (in the Microsoft.VisualBasic namespace) to run an external process and wait for its termination, but you can get better control if you work

FormatMemorySize – Format a value in bytes

Enum FormatMemorySizeUnits BestGuess Bytes Kilobytes Megabytes GigabytesEnd Enum’ convert a number of bytes into Kbytes, Megabytes, or GigabytesFunction FormatMemorySize(ByVal value As Long, _ ByVal unit As FormatMemorySizeUnits, Optional ByVal decimalDigits