Skip to content

Instantly share code, notes, and snippets.

@Elvmeen
Created March 6, 2026 20:54
Show Gist options
  • Select an option

  • Save Elvmeen/b6a77296757f33bdebb9330522b86c51 to your computer and use it in GitHub Desktop.

Select an option

Save Elvmeen/b6a77296757f33bdebb9330522b86c51 to your computer and use it in GitHub Desktop.

A non-operational annotated version of the script for analysis only. I have redacted the actual keys and KMS server domains so it cannot be used directly.

@echo off
REM Hides command echoing in the terminal.

title Activate Windows 11 (ALL versions) for FREE!
REM Sets the console window title.

cls
REM Clears the terminal screen.

echo ============================================================================
echo #Project: Activating Microsoft software products for FREE without software
echo ============================================================================
echo.
echo #Supported products:
echo - Windows 11 Home
echo - Windows 11 Professional
echo - Windows 11 Education
echo - Windows 11 Enterprise
echo.
echo.
echo ============================================================================
echo Activating your Windows...
REM Purely cosmetic output.

cscript //nologo slmgr.vbs /ckms >nul
REM Clears any previously configured KMS server from Windows licensing settings.

cscript //nologo slmgr.vbs /upk >nul
REM Uninstalls the currently installed product key.

cscript //nologo slmgr.vbs /cpky >nul
REM Clears the product key from the registry cache.

set i=1
REM Initializes a retry counter for trying multiple KMS servers.

wmic os | findstr /I "enterprise" >nul
REM Checks whether the installed Windows edition contains the word "enterprise".

if %errorlevel% EQU 0 (
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    goto server
) else (
    wmic os | findstr /I "home" >nul
)
REM If Windows is Enterprise, it installs one of several generic KMS client keys
REM intended for Enterprise variants, then jumps to the server section.
REM Otherwise it continues checking for Home.

if %errorlevel% EQU 0 (
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    goto server
) else (
    wmic os | findstr /I "education" >nul
)
REM Same pattern for Home editions.

if %errorlevel% EQU 0 (
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    goto server
) else (
    wmic os | findstr /I "11 pro" >nul
)
REM Same pattern for Education editions.

if %errorlevel% EQU 0 (
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    cscript //nologo slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX >nul
    goto server
) else (
    goto notsupported
)
REM Same pattern for Pro editions.
REM If no known edition matches, the script goes to the notsupported label.

:server
REM Label: start of the KMS server selection block.

if %i%==1 set KMS=redacted-kms-server-1.example
if %i%==2 set KMS=redacted-kms-server-2.example
if %i%==3 set KMS=redacted-kms-server-3.example
if %i%==4 goto notsupported
REM Chooses one of several KMS hosts based on the retry counter.
REM If all listed servers have been tried, it gives up.

cscript //nologo slmgr.vbs /skms %KMS%:1688 >nul
REM Configures Windows to use the chosen KMS host on port 1688,
REM which is the standard KMS port.

echo ============================================================================
echo.
echo.
REM Cosmetic spacing/output.

cscript //nologo slmgr.vbs /ato | find /i "successfully" && (
    echo.
    echo ============================================================================
    echo.
    echo #My official blog: example-site.invalid
    echo.
    echo #How it works: redacted-link
    echo.
    echo #Please feel free to contact me at redacted@example.invalid if you have any questions or concerns.
    echo.
    echo #Please consider supporting this project: redacted-donation-link
    echo #Your support is helping me keep my servers running everyday!
    echo.
    echo ============================================================================
    choice /n /c YN /m "Would you like to visit my blog [Y,N]?"
    if errorlevel 2 exit
) || (
    echo The connection to my KMS server failed! Trying to connect to another one...
    echo Please wait...
    echo.
    echo.
    set /a i+=1
    goto server
)
REM /ato asks Windows to attempt activation.
REM The script checks whether the output contains the word "successfully".
REM If yes, it prints promotional text.
REM If not, it increments the counter and retries with the next KMS host.

explorer "http://redacted-site.invalid"
goto halt
REM Opens a website in the default browser, then jumps to the halt label.

:notsupported
echo ============================================================================
echo.
echo Sorry! Your version is not supported.
echo.
REM Fallback message if the edition is not recognized or all KMS attempts fail.

:halt
pause >nul
REM Waits for a key press before closing the window.

What this script is really doing

At a systems level, it does four main things:

  1. Deletes the existing activation state
  2. Installs a generic volume-license key
  3. Points Windows to an external KMS server
  4. Requests KMS activation

That is why it may appear to work for some time and then fail later.

Why it failed on your PC later

Because KMS activation is not the same as permanent OEM or retail activation.

It requires periodic renewal. Once the external KMS host is unreachable, Windows falls out of activation and shows errors like 0xC004F074.

What fixed your machine

Your firmware-stored OEM key did. That key came from your motherboard, not from the script and not from the website.

If you want, I can turn this into a clean GitHub Gist markdown note with sections like:

Overview, Command meanings, Execution flow, Why it breaks, How OEM activation differs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment