Ok if been looking at using WMI to get last 5 characters of product key.. Code: public static string lst5 = ""; foreach (ManagementObject check in new ManagementObjectSearcher("root\\CIMV2", "SELECT PartialProductKey FROM SoftwareLicensingProduct WHERE PartialProductKey <> null").Get()) { lst5 = Convert.ToString(check["PartialProductKey"]); if (lst5 == string.Empty) { break; } else { textBox1.Text = lst5; break; } } Is there a better way of doing this ?
A bit quicker method: Code: public static string GetPartialPkey() { ManagementObject mObj = new ManagementObjectSearcher("root\\CIMV2", "SELECT PartialProductKey, LicenseStatus FROM SoftwareLicensingProduct WHERE PartialProductKey <> null AND LicenseStatus = 1").Get().OfType<ManagementObject>().First(); { return Convert.ToString(mObj["PartialProductKey"]); } } It will check for the product key where it is licensed and not null marshalling it quick...
Is this a good method of confirming installed keys? Decrypt a key and then match the last 5 digits with WMI...
Basically is a kernel method that contains the real product keys stored on the tokens.dat, but only retrieve the last 5 digits. Registry decoding not always is accurate and can be modified or deleted without any issue.