SLMGR - CMD


Overview

SLMGR, or Software Licensing Management Tool, is a command-line tool intended for Windows system administrators to manage licenses and activation status on Windows operating systems. This utility allows for various operations, including activating the operating system using a Key Management Service (KMS) or configuring licensing tokens and settings. Generally used in enterprise environments, SLMGR is crucial for volume licensing setups and helps ensure compliance with Microsoft’s licensing terms.

Syntax

The general syntax for using SLMGR is as follows:

slmgr [MachineName [Username Password]] [Option]
  • MachineName: Specifies the target machine. The local machine is used if this parameter is omitted.
  • Username and Password: Use these parameters to provide administrative credentials for the target machine, if needed.
  • Option: One or more options to be executed (explained in detail in the Options/Flags section).

Here are variations of its command structure depending on administrative needs:

slmgr.vbs [MachineName [Username Password]] [Option]

Options/Flags

  • /ipk [ProductKey]: Install product key (replaces existing key with a new one).
  • /ato [Activation ID]: Activate Windows.
  • /dli [Activation ID | All]: Display license information.
  • /dlv [Activation ID | All]: Display detailed license information.
  • /xpr [Activation ID]: Display the expiration date for current license state.
  • /upk [Activation ID]: Uninstall product key.
  • /cpky: Clear product key from the registry (prevents disclosure attacks).
  • /ilc [LicenseFile]: Install license.
  • /rilc: Reinstall system license files.
  • /rearm: Reset the licensing status of the machine.

Each option affects the system’s licensing configuration in specific ways, which should be used with caution to prevent accidental misconfiguration.

Examples

  1. Install a New Product Key:

    slmgr /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
    

    Replace XXXXX-XXXXX-XXXXX-XXXXX-XXXXX with your actual product key.

  2. Activate Windows:

    slmgr /ato
    
  3. Display Detailed License Information:

    slmgr /dlv
    
  4. Uninstall the Product Key:

    slmgr /upk
    
  5. Reset Licensing Status of the Machine:

    slmgr /rearm
    

Common Issues

  • Error: 0xC004F074: No Key Management Service (KMS) could be contacted. Ensure that the KMS host is reachable, properly configured, and that you have network connectivity.
  • Access Denied Errors: Ensure that command prompt is run as Administrator.
  • Script Host Errors: Make sure that the script is being run with proper syntax and check for spelling errors in the options.

Integration

SLMGR can be combined with other scripts or tasks in complex deployment environments. For instance, it can be scripted to run after deployment to activate systems automatically:

cscript C:\Windows\System32\slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
cscript C:\Windows\System32\slmgr.vbs /ato

Incorporating it in PowerShell scripts or batch files can help automate wider system management tasks.

  • cscript: Used to execute .vbs scripts, such as slmgr.vbs.
  • VBS: General reference to the type of scripts managed by Windows Script Host, like SLMGR.

For further reading and more detailed information, refer to the official Microsoft documentation: Volume Activation Management Tool (VAMT).