Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

dalouc/windows-activation-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Windows Activation Script

A PowerShell script for installing and activating Windows using a valid product license key. This tool provides a streamlined command-line interface for Windows activation with proper error handling and status reporting.

Overview

This script automates the Windows activation process by installing a product key and triggering the activation sequence through Windows Management Instrumentation (WMI). It includes validation checks, administrator privilege verification, and detailed status reporting to ensure a smooth activation experience.

Features

  • Automated License Installation: Installs Windows product keys programmatically
  • Activation Trigger: Initiates the Windows activation process
  • Status Reporting: Provides detailed activation status with clear visual feedback
  • Input Validation: Validates product key format before processing
  • Error Handling: Comprehensive error catching and user-friendly error messages
  • Administrator Check: Verifies script is run with required privileges
  • Color-Coded Output: Visual feedback using colored console messages

Requirements

  • Operating System: Windows (any edition that supports activation)
  • PowerShell: Version 5.1 or higher
  • Privileges: Administrator rights (required)
  • Valid Product Key: A legitimate Windows license key in the format XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Installation

  1. Download the windows-activation.ps1 script to your local machine

  2. Open the script in a text editor

  3. Locate the configuration section at the top of the file:

# CONFIGURATION - Enter your license key here
$LicenseKey = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
  1. Replace the placeholder with your actual Windows product key:
$LicenseKey = "ABCDE-12345-FGHIJ-67890-KLMNO"
  1. Save the file

Usage

Running the Script

  1. Open PowerShell as Administrator:

    • Right-click the Start menu
    • Select "Windows PowerShell (Admin)" or "Terminal (Admin)"
  2. Navigate to the script directory:

cd C:\path\to\script
  1. Execute the script:
.\windows-activation.ps1

Expected Output

Successful activation:

========================================
   Windows Activation Script
========================================

Installing product key...
Product key installed successfully.
Activating Windows...
Activation completed.

========================================
   Activation Status
========================================
Status: Licensed (Activated)

Windows has been activated successfully!

Project Structure

windows-activation-script/
├── windows-activation.ps1    # Main PowerShell activation script
└── README.md

Script Components

The script is organized into the following sections:

  • Configuration Section: Where the license key is defined
  • Functions:
    • Test-AdminPrivileges: Checks if the script is running with administrator rights
    • Install-ProductKey: Installs the Windows product key using WMI
    • Invoke-WindowsActivation: Triggers the Windows activation process
    • Get-ActivationStatus: Retrieves and formats the current activation status
  • Main Execution Block: Orchestrates the activation workflow

Configuration

License Key Format

The product key must follow this exact format:

  • 5 groups of 5 characters
  • Separated by hyphens
  • Alphanumeric characters (A-Z, 0-9)
  • Example: ABCDE-12345-FGHIJ-67890-KLMNO

Activation Status Codes

The script reports the following status codes:

Code Status Description
0 Unlicensed Windows is not activated
1 Licensed (Activated) Windows is successfully activated
2 Out-of-Box Grace Period Initial grace period active
3 Out-of-Tolerance Grace Period Hardware changes detected
4 Non-Genuine Grace Period Validation issues
5 Notification Activation notification state
6 Extended Grace Period Extended grace period active

Notes and Limitations

Important Considerations

  • Valid License Required: This script only works with legitimate Windows product keys. It does not bypass activation or provide unauthorized licenses.

  • Internet Connection: Windows activation typically requires an internet connection to communicate with Microsoft's activation servers. Offline activation may require additional steps not covered by this script.

  • One-Time Configuration: The license key is hardcoded in the script. For security reasons, avoid sharing the configured script file.

  • Regional Restrictions: Some product keys are region-specific and may not work in all geographic locations.

  • Edition Compatibility: Ensure your product key matches your Windows edition (Home, Pro, Enterprise, etc.).

Known Limitations

  • The script does not support batch activation of multiple machines
  • No built-in rollback mechanism if activation fails
  • Requires manual editing of the script file to change the product key

Troubleshooting

Common Issues

Error: "This script requires Administrator privileges"

  • Solution: Run PowerShell as Administrator

Error: "The key format is not valid"

  • Solution: Verify your product key follows the format XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Error: "Error installing key"

  • Solution: Ensure the product key is valid and matches your Windows edition

Status shows "Unlicensed" after activation

  • Solution: Check your internet connection and wait a few minutes for activation to process

About

Windows Activation Script

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors