🟣 C# / .NET 6+
Get Processes Report (C#)
Queries Win32_Process via WMI (System.Management) and prints Processes to the console.
GetProcessReport.cs
// GetProcessReport.cs
//
// Reports Processes via WMI (Win32_Process).
//
// Requires the System.Management package:
// dotnet new console -o ProcessReport
// dotnet add package System.Management
// (replace the generated Program.cs with this file, then dotnet run)
// On .NET Framework, System.Management is already available — just
// add a reference to it in your project.
using System;
using System.Management;
var searcher = new ManagementObjectSearcher("SELECT Name, ProcessId, WorkingSetSize, ThreadCount FROM Win32_Process");
int count = 0;
foreach (ManagementObject item in searcher.Get())
{
Console.WriteLine($"Name: {item["Name"]}");
Console.WriteLine($"ProcessId: {item["ProcessId"]}");
Console.WriteLine($"WorkingSetSize: {item["WorkingSetSize"]}");
Console.WriteLine($"ThreadCount: {item["ThreadCount"]}");
Console.WriteLine(new string('-', 40));
count++;
}
if (count == 0)
{
Console.WriteLine("No Processes found.");
}
else
{
Console.WriteLine($"\n{count} Processes found.");
}