-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
19 lines (17 loc) · 838 Bytes
/
Copy pathProgram.cs
File metadata and controls
19 lines (17 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System.Management;
if (!Environment.IsPrivilegedProcess) {
Console.WriteLine("ERROR: Admin privileges required.");
Environment.Exit(-1);
}
// Doc: https://learn.microsoft.com/en-us/windows/win32/wmisdk/win32-installedwin32program
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_InstalledWin32Program");
foreach (ManagementObject mo in mos.Get()) {
Console.WriteLine();
Console.WriteLine("Program: " + mo["Name"] + ":");
Console.WriteLine(" Vendor: " + mo["Vendor"]);
Console.WriteLine(" Version: " + mo["Version"]);
Console.WriteLine(" Language: " + mo["Language"]);
Console.WriteLine(" ProgramId: " + mo["ProgramId"]);
Console.WriteLine(" MsiPackageCode: " + mo["MsiPackageCode"]);
Console.WriteLine(" MsiProductCode: " + mo["MsiProductCode"]);
}