Ejemplo n.º 1
0
        // assumes correct product key is the only one installed
        public static bool KmsActivate(IPAddress ipa)
        {
            // set kms server address
            Logger.Debug("Setting KMS address");
            ManagementObject sls = WmiQuery.GetFirst("SELECT * FROM SoftwareLicensingService");

            sls.InvokeMethod("SetKeyManagementServiceMachine", new object[] { ipa.ToString() });

            // get VL product object
            Logger.Debug("Getting Volume License product object");
            ManagementObject wslp = WmiQuery.GetFirst(
                "SELECT ID FROM SoftwareLicensingProduct WHERE " + WINDOWS_ACTIVE_PRODUCT_WHERE);

            if (wslp == null)
            {
                Logger.Error("Volume License product not activated");
                return(false);
            }

            // activate Windows
            Logger.Debug("Activating Windows");
            wslp.InvokeMethod("Activate", new object[0]);

            // refresh licensing status
            Logger.Debug("Refreshing licensing status");
            sls.InvokeMethod("RefreshLicenseStatus", new object[0]);

            return(true);
        }
Ejemplo n.º 2
0
        public static void SetProductKey(string productKey)
        {
            // clear current product key(s)
            ClearProductKeys();

            // install new product key
            ManagementObject sls = WmiQuery.GetFirst("SELECT * FROM SoftwareLicensingService");

            Logger.Debug("Installing new Product key");
            sls.InvokeMethod("InstallProductKey", new object[] { productKey });

            // refresh licensing status
            Logger.Debug("Refreshing licensing status");
            sls.InvokeMethod("RefreshLicenseStatus", new object[0]);
        }
Ejemplo n.º 3
0
 private static ManagementObject GetVlmcsdService()
 => WmiQuery.GetFirst(
     "SELECT * FROM Win32_Service " +
     "WHERE Name = \"vlmcsd\" AND " +
     "StartMode <> \"Disabled\""
     );
Ejemplo n.º 4
0
 public static string GetWindowsSKU()
 => WmiQuery.GetFirst("SELECT Caption FROM Win32_OperatingSystem")["caption"]?.ToString();