🟣 C# / .NET 6+

Get Computer System Product Info Report (C#)

Queries Win32_ComputerSystemProduct via WMI (System.Management) and prints Computer System Product Info to the console.

By WindowsScripting.com · 1.1 KB
GetComputerSystemProductReport.cs
// GetComputerSystemProductReport.cs
//
// Reports Computer System Product Info via WMI (Win32_ComputerSystemProduct).
//
// Requires the System.Management package:
//   dotnet new console -o ComputerSystemProductReport
//   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, Vendor, Version, IdentifyingNumber FROM Win32_ComputerSystemProduct");
int count = 0;

foreach (ManagementObject item in searcher.Get())
{
    Console.WriteLine($"Name: {item["Name"]}");
    Console.WriteLine($"Vendor: {item["Vendor"]}");
    Console.WriteLine($"Version: {item["Version"]}");
    Console.WriteLine($"IdentifyingNumber: {item["IdentifyingNumber"]}");
    Console.WriteLine(new string('-', 40));
    count++;
}

if (count == 0)
{
    Console.WriteLine("No Computer System Product Info found.");
}
else
{
    Console.WriteLine($"\n{count} Computer System Product Info found.");
}