public static void ClearProductKeys() { // uninstall all installed Windows product keys Logger.Debug("Querying installed licenses"); List <ManagementObject> licensedProducts = WmiQuery.GetAll( "SELECT ID FROM SoftwareLicensingProduct WHERE " + WINDOWS_ACTIVE_PRODUCT_WHERE); Logger.Debug("Removing " + licensedProducts.Count.ToString() + " installed license(s)"); foreach (ManagementObject p in licensedProducts) { p.InvokeMethod("UninstallProductKey", new object[0]); } }
public static List <Tap0901Device> GetAllTap0901Devices() { List <ManagementObject> devs = WmiQuery.GetAll( "SELECT NetConnectionID, PNPDeviceID FROM Win32_NetworkAdapter " + "WHERE ServiceName = 'tap0901'" ); List <Tap0901Device> wrappedDevs = new List <Tap0901Device>(); foreach (ManagementObject m in devs) { wrappedDevs.Add(new Tap0901Device(m)); } Logger.Debug("Found " + wrappedDevs.Count.ToString() + " Tap device(s)"); return(wrappedDevs); }
public static string GetProductKey() { string regPk = WinProdKeyFind.GetWindowsProductKeyFromRegistry(); if (regPk == null) { return(null); } // check if the product key is effectively installed List <ManagementObject> licensedProducts = WmiQuery.GetAll( "SELECT ID FROM SoftwareLicensingProduct WHERE " + "PartialProductKey = \"" + regPk.Substring(regPk.Length - 5) + "\" AND " + WINDOWS_PRODUCT_WHERE ); if (licensedProducts.Count > 0) { return(regPk); } return(null); }