A complete Python conversion of Microsoft's slmgr.vbs script for managing Windows licensing and activation. This tool provides command-line management of Windows Software Protection Platform (SPP) with full feature parity to the original VBScript version.
- Full Feature Parity: All 30+ commands from the original slmgr.vbs
- License Management: Install, uninstall, display, and activate Windows product keys
- KMS Support: Complete Key Management Service client and server configuration
- Token-based Activation: Manage and force token-based activation
- Active Directory Activation: Configure and manage AD-based activation
- Remote Execution: Manage licensing on remote computers
- AVMA Support: Automatic VM Activation for virtualized environments
- Python: 3.10 or higher
- Operating System: Windows 10/11 or Windows Server 2016+
- Python Packages:
- pywin32
- wmi
- Permissions: Administrator/elevated privileges required for most operations
- Clone this repository:
git clone https://github.com/tboy1337/slmgr-py.git
cd slmgr-py- Install required packages:
pip install -r requirements.txtpython slmgr.py [MachineName [User Password]] [Option]MachineName: Name of remote machine (default is local machine)User: Account with required privilege on remote machinePassword: Password for the account
# Display current license
python slmgr.py /dli
# Display detailed license information
python slmgr.py /dlv
# Display all licenses
python slmgr.py /dli all# Install product key
python slmgr.py /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
# Uninstall current product key
python slmgr.py /upk
# Clear product key from registry
python slmgr.py /cpky# Activate Windows online
python slmgr.py /ato
# Get Installation ID for phone activation
python slmgr.py /dti
# Activate with Confirmation ID (phone activation)
python slmgr.py /atp <Confirmation-ID>
# Check activation expiration
python slmgr.py /xpr# Set KMS server
python slmgr.py /skms kms.example.com:1688
# Clear KMS server
python slmgr.py /ckms
# Set KMS DNS lookup domain
python slmgr.py /skms-domain example.com
# Enable/disable KMS host caching
python slmgr.py /skhc # Enable
python slmgr.py /ckhc # Disable# Set KMS listening port
python slmgr.py /sprt 1688
# Set activation/renewal intervals
python slmgr.py /sai 120 # 120 minutes
python slmgr.py /sri 10080 # 7 days
# Enable/disable DNS publishing
python slmgr.py /sdns # Enable
python slmgr.py /cdns # Disable
# Set KMS priority
python slmgr.py /spri # Normal
python slmgr.py /cpri # Low
# Set activation type
python slmgr.py /act-type 2 # 0=All, 1=AD, 2=KMS, 3=Token# List installed issuance licenses
python slmgr.py /lil
# Remove issuance license
python slmgr.py /ril <ILID> <ILvID>
# List TKA certificates
python slmgr.py /ltc
# Force token activation
python slmgr.py /fta <Thumbprint> [PIN]# Activate AD forest online
python slmgr.py /ad-activation-online <Product-Key> [AO-Name]
# Get AD Installation ID
python slmgr.py /ad-activation-get-iid <Product-Key>
# Activate AD forest with CID
python slmgr.py /ad-activation-apply-cid <Product-Key> <CID> [AO-Name]
# List activation objects
python slmgr.py /ao-list
# Delete activation object
python slmgr.py /del-ao <AO-DN># Install license file
python slmgr.py /ilc license.xrm-ms
# Reinstall all system licenses
python slmgr.py /rilc# Rearm Windows (reset grace period)
python slmgr.py /rearm
# Rearm specific application
python slmgr.py /rearm-app <Application-ID>
# Rearm specific SKU
python slmgr.py /rearm-sku <Activation-ID>Execute commands on remote computers:
# Local authentication
python slmgr.py COMPUTER /dli
# With credentials
python slmgr.py COMPUTER username password /dliNote: Some commands (AD activation, token activation) do not support remote execution.
| Option | Parameters | Description |
|---|---|---|
/ipk |
<Product Key> |
Install product key |
/ato |
[Activation ID] |
Activate Windows |
/dli |
[Activation ID|All] |
Display license information |
/dlv |
[Activation ID|All] |
Display detailed license information |
/xpr |
[Activation ID] |
Display expiration date |
| Option | Parameters | Description |
|---|---|---|
/cpky |
None | Clear product key from registry |
/ilc |
<License file> |
Install license file |
/rilc |
None | Reinstall system license files |
/rearm |
None | Reset licensing status |
/rearm-app |
<Application ID> |
Reset app licensing status |
/rearm-sku |
<Activation ID> |
Reset SKU licensing status |
/upk |
[Activation ID] |
Uninstall product key |
/dti |
[Activation ID] |
Display Installation ID |
/atp |
<Confirmation ID> [Activation ID] |
Phone activation |
This Python version maintains command-line compatibility with the original slmgr.vbs:
# VBScript version
cscript slmgr.vbs /dli
# Python version - same syntax
python slmgr.py /dli- Syntax: Use
python slmgr.pyinstead ofcscript slmgr.vbs - Performance: Generally faster execution due to Python's performance
- Error Messages: Enhanced error reporting with Python stack traces
- Type Safety: Full type annotations for better code reliability
- Cross-platform Readability: Python code is more maintainable
# Configure client to use KMS server
python slmgr.py /skms kms.corp.local:1688
# Activate against KMS
python slmgr.py /ato
# Verify activation
python slmgr.py /dli# Install MAK key
python slmgr.py /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
# Activate online
python slmgr.py /ato
# Check remaining activations (if MAK)
python slmgr.py /dlv# Get Installation ID
python slmgr.py /dti
# (Call Microsoft activation center with IID, receive Confirmation ID)
# Apply Confirmation ID
python slmgr.py /atp CONFIRMATION-ID# Display detailed license info
python slmgr.py /dlv
# Check expiration
python slmgr.py /xpr
# Reinstall licenses if corrupted
python slmgr.py /rilc
# Rearm if in grace period
python slmgr.py /rearm- Elevated Privileges: Most operations require administrator rights
- Product Keys: Handle product keys securely, never log or display
- Remote Access: Use secure credentials for remote operations
- Registry Access: Be cautious with
/cpkyas it permanently removes keys - Network: KMS traffic uses port 1688 (TCP)
"Access denied" errors
- Run PowerShell or Command Prompt as Administrator
- Ensure user has appropriate permissions
"Cannot connect to WMI" errors
- Check Windows Management Instrumentation service is running
- Verify firewall allows WMI traffic for remote operations
"Product not found" errors
- Ensure Windows is properly licensed
- Check that a product key is installed (
/dli)
KMS activation fails
- Verify KMS server is reachable (
ping kms-server) - Check port 1688 is not blocked
- Ensure client count meets threshold (25 for client OS, 5 for server)
Contributions are welcome! Please:
- Maintain Python 3.10+ compatibility
- Follow existing code style (Black, isort)
- Add type hints for all functions
- Include tests for new features
- Update documentation