' ' Copyright (c) Microsoft Corporation. All rights reserved. ' ' Windows Software Licensing Management Tool. ' ' Script Name: slmgr.vbs ' Option Explicit Dim g_objWMIService, g_strComputer, g_strUserName, g_strPassword, g_IsRemoteComputer g_strComputer = "." g_IsRemoteComputer = False dim g_EchoString g_EchoString = "" dim g_objRegistry Dim g_resourceDictionary, g_resourcesLoaded Set g_resourceDictionary = CreateObject("Scripting.Dictionary") g_resourcesLoaded = False Dim g_DeterminedDisplayFlags g_DeterminedDisplayFlags = False Dim g_ShowKmsInfo Dim g_ShowKmsClientInfo Dim g_ShowTkaClientInfo Dim g_ShowTBLInfo Dim g_ShowPhoneInfo g_ShowKmsInfo = False g_ShowKmsClientInfo = false g_ShowTBLInfo = False g_ShowPhoneInfo = False ' Messages 'Global options private const L_optInstallProductKey = "ipk" private const L_optInstallProductKeyUsage = "Install product key (replaces existing key)" private const L_optUninstallProductKey = "upk" private const L_optUninstallProductKeyUsage = "Uninstall product key" private const L_optActivateProduct = "ato" private const L_optActivateProductUsage = "Activate Windows" private const L_optDisplayInformation = "dli" private const L_optDisplayInformationUsage = "Display license information (default: current license)" private const L_optDisplayInformationVerbose = "dlv" private const L_optDisplayInformationUsageVerbose = "Display detailed license information (default: current license)" private const L_optExpirationDatime = "xpr" private const L_optExpirationDatimeUsage = "Expiration date for current license state" 'Advanced options private const L_optClearPKeyFromRegistry = "cpky" private const L_optClearPKeyFromRegistryUsage = "Clear product key from the registry (prevents disclosure attacks)" private const L_optInstallLicense = "ilc" private const L_optInstallLicenseUsage = "Install license" private const L_optReinstallLicenses = "rilc" private const L_optReinstallLicensesUsage = "Re-install system license files" private const L_optDisplayIID = "dti" private const L_optDisplayIIDUsage = "Display Installation ID for offline activation" private const L_optPhoneActivateProduct = "atp" private const L_optPhoneActivateProductUsage = "Activate product with user-provided Confirmation ID" private const L_optReArmWindows = "rearm" private const L_optReArmWindowsUsage = "Reset the licensing status of the machine" private const L_optReArmApplication = "rearm-app" private const L_optReArmApplicationUsage = "Reset the licensing status of the given app" private const L_optReArmSku = "rearm-sku" private const L_optReArmSkuUsage = "Reset the licensing status of the given sku" 'KMS options private const L_optSetKmsName = "skms" private const L_optSetKmsNameUsage = "Set the name and/or the port for the KMS computer this machine will use. IPv6 address must be specified in the format [hostname]:port" private const L_optClearKmsName = "ckms" private const L_optClearKmsNameUsage = "Clear name of KMS computer used (sets the port to the default)" private const L_optSetKmsLookupDomain = "skms-domain" private const L_optSetKmsLookupDomainUsage = "Set the specific DNS domain in which all KMS SRV records can be found. This setting has no effect if the specific single KMS host is set via /skms option." private const L_optClearKmsLookupDomain = "ckms-domain" private const L_optClearKmsLookupDomainUsage = "Clear the specific DNS domain in which all KMS SRV records can be found. The specific KMS host will be used if set via /skms. Otherwise default KMS auto-discovery will be used." private const L_optSetKmsHostCaching = "skhc" private const L_optSetKmsHostCachingUsage = "Enable KMS host caching" private const L_optClearKmsHostCaching = "ckhc" private const L_optClearKmsHostCachingUsage = "Disable KMS host caching" private const L_optSetActivationInterval = "sai" private const L_optSetActivationIntervalUsage = "Set interval (minutes) for unactivated clients to attempt KMS connection. The activation interval must be between 15 minutes (min) and 30 days (max) although the default (2 hours) is recommended." private const L_optSetRenewalInterval = "sri" private const L_optSetRenewalIntervalUsage = "Set renewal interval (minutes) for activated clients to attempt KMS connection. The renewal interval must be between 15 minutes (min) and 30 days (max) although the default (7 days) is recommended." private const L_optSetKmsListenPort = "sprt" private const L_optSetKmsListenPortUsage = "Set TCP port KMS will use to communicate with clients" private const L_optSetDNS = "sdns" private const L_optSetDNSUsage = "Enable DNS publishing by KMS (default)" private const L_optClearDNS = "cdns" private const L_optClearDNSUsage = "Disable DNS publishing by KMS" private const L_optSetNormalPriority = "spri" private const L_optSetNormalPriorityUsage = "Set KMS priority to normal (default)" private const L_optClearNormalPriority = "cpri" private const L_optClearNormalPriorityUsage = "Set KMS priority to low" private const L_optSetVLActivationType = "act-type" private const L_optSetVLActivationTypeUsage = "Set activation type to 1 (for AD) or 2 (for KMS) or 3 (for Token) or 0 (for all)." ' Token-based Activation options private const L_optListInstalledILs = "lil" private const L_optListInstalledILsUsage = "List installed Token-based Activation Issuance Licenses" private const L_optRemoveInstalledIL = "ril" private const L_optRemoveInstalledILUsage = "Remove installed Token-based Activation Issuance License" private const L_optListTkaCerts = "ltc" private const L_optListTkaCertsUsage = "List Token-based Activation Certificates" private const L_optForceTkaActivation = "fta" private const L_optForceTkaActivationUsage = "Force Token-based Activation" ' Active Directory Activation options private const L_optADActivate = "ad-activation-online" private const L_optADActivateUsage = "Activate AD (Active Directory) forest with user-provided product key" private const L_optADGetIID = "ad-activation-get-iid" private const L_optADGetIIDUsage = "Display Installation ID for AD (Active Directory) forest" private const L_optADApplyCID = "ad-activation-apply-cid" private const L_optADApplyCIDUsage = "Activate AD (Active Directory) forest with user-provided product key and Confirmation ID" private const L_optADListAOs = "ao-list" private const L_optADListAOsUsage = "Display Activation Objects in AD (Active Directory)" private const L_optADDeleteAO = "del-ao" private const L_optADDeleteAOsUsage = "Delete Activation Objects in AD (Active Directory) for user-provided Activation Object" ' Option parameters private const L_ParamsActivationID = "" private const L_ParamsActivationIDOptional = "[Activation ID]" private const L_ParamsActIDOptional = "[Activation ID | All]" private const L_ParamsApplicationID = "" private const L_ParamsProductKey = "" private const L_ParamsLicenseFile = "" private const L_ParamsPhoneActivate = "" private const L_ParamsSetKms = "" private const L_ParamsSetKmsLookupDomain = "" private const L_ParamsSetListenKmsPort = "" private const L_ParamsSetActivationInterval = "" private const L_ParamsSetRenewalInterval = "" private const L_ParamsVLActivationTypeOptional = "[Activation-Type]" private const L_ParamsRemoveInstalledIL = " " private const L_ParamsForceTkaActivation = " []" private const L_ParamsAONameOptional = "[Activation Object name]" private const L_ParamsAODistinguishedName = "" ' Miscellaneous messages private const L_MsgHelp_1 = "Windows Software Licensing Management Tool" private const L_MsgHelp_2 = "Usage: slmgr.vbs [MachineName [User Password]] [