Get all system processes with C#

List all System running processes with the following code:

public void GetAllProcesses()
{
    foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses())
    {
        try
        {
    	    Console.WriteLine(
		proc.Id + " " + proc.ProcessName + " " + 
		proc.PriorityClass.ToString() + " " + 
		proc.MainModule.FileName);
        }
        catch (Exception)
        {
	    //...
        }			
}
}
Categories: C# Tags: , , , ,
%d bloggers like this: