    @echo off

    rem  请不要修改本文档
    rem author : 默然King
    rem url : http://bbs.pcbeta.com/forum.php?mod=viewthread&tid=1786788&page=1#pid48314667

    color 1f
    title 正在激活 Windows，请不要关闭本窗口。

    cls
    cd /d "%~dp0"
    ping /n 2 www.baidu.com >nul 2>nul && goto StartActive
    ping /n 2 www.qq.com >nul 2>nul || exit

    :StartActive
    wmic path SoftwareLicensingProduct where (LicenseStatus='1' and GracePeriodRemaining='0') get Name 2>nul | findstr /i "Windows" >nul 2>&1 && (goto end)
    for /f "tokens=6 delims=[]. " %%a in ('ver') do (set version=%%a)

    reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t REG_DWORD /d "0" /f >nul
    for /f "tokens=3 delims= " %%i in ('cscript /nologo %SystemRoot%\System32\slmgr.vbs /dli ^| findstr /i "edition"') do (set edition=%%i)
    call :%edition%

    cscript /nologo %SystemRoot%\System32\slmgr.vbs /ipk %pidkey% || goto quit
    timeout /nobreak /t 2 >nul

    reg add "HKLM\SYSTEM\Tokens" /v "Channel" /t REG_SZ /d "%License%" /f >nul
    reg add "HKLM\SYSTEM\Tokens\Kernel" /v "Kernel-ProductInfo" /t REG_DWORD /d "%sku%" /f >nul
    reg add "HKLM\SYSTEM\Tokens\Kernel" /v "Security-SPP-GenuineLocalStatus" /t REG_DWORD /d "1" /f >nul
    reg add "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "\"%~dp0bin\%ActiveType%\gatherosstate.exe"\" /d "^ WIN7RTM" /f >nul

    if /i "%License:~-4%" equ "GVLK" (
    set "ActiveType=KMS38"
    ) else (
    set "ActiveType=Digital"
      )

    set "number=0"
    :Reset
    set /a "number=%number%+1"
    start /wait "" ".\bin\%ActiveType%\gatherosstate.exe"
    timeout /nobreak /t 3 >nul
    if exist ".\bin\%ActiveType%\GenuineTicket.xml" (
    goto app
        )
    if "%number%" lss "3" (
    goto Reset
        )
    goto quit

    :app
    clipup -v -o -altto .\bin\%ActiveType%\

    if /i "%License:~-4%" equ "GVLK" (
    cscript /nologo %SystemRoot%\system32\slmgr.vbs /skms "127.0.0.1"
    ) else (
    cscript /nologo %SystemRoot%\system32\slmgr.vbs /ato
      )

    :quit
    reg delete "HKLM\SYSTEM\Tokens" /f >nul
    reg delete "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "\"%~dp0bin\%ActiveType%\gatherosstate.exe"\" /f >nul
    reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t REG_DWORD /d "1" /f >nul

    :end
    rmdir /q /s "%SystemRoot%\Setup\Scripts\bin"
    del %0
    exit

    :Cloud
    if "%version%" equ "16299" (
    set "sku=178"
    set "pidkey=V3WVW-N2PV2-CGWC3-34QGF-VMJ2C"
    set "License=Retail"
    set "skus=Cloud"
    goto :eof
    ) else (
    goto end
      )

    :CloudN
    if "%version%" equ "16299" (
    set "sku=179"
    set "pidkey=NH9J3-68WK7-6FB93-4K3DF-DJ4F6"
    set "License=Retail"
    set "skus=CloudN"
    goto :eof
    ) else (
    goto end
      )

    :Core
    set "sku=101"
    set "pidkey=YTMG3-N6DKC-DKB77-7M9GH-8HVX7"
    set "License=Retail"
    set "skus=Core"
    goto :eof

    :CoreN
    set "sku=98"
    set "pidkey=4CPRK-NM3K3-X6XXQ-RXX86-WXCHW"
    set "License=Retail"
    set "skus=CoreN"
    goto :eof

    :CoreCountrySpecific
    set "sku=99"
    set "pidkey=N2434-X9D7W-8PF6X-8DV9T-8TYMD"
    set "License=Retail"
    set "skus=CoreCountrySpecific"
    goto :eof

    :CoreSingleLanguage
    set "sku=100"
    set "pidkey=BT79Q-G7N6G-PGBYW-4YWX6-6F4BT"
    set "License=Retail"
    set "skus=CoreSingleLanguage"
    goto :eof

    :Professional
    set "sku=48"
    set "pidkey=VK7JG-NPHTM-C97JM-9MPGT-3V66T"
    set "License=Retail"
    set "skus=Professional"
    goto :eof

    :ProfessionalN
    set "sku=49"
    set "pidkey=2B87N-8KFHP-DKV6R-Y2C8J-PKCKT"
    set "License=Retail"
    set "skus=ProfessionalN"
    goto :eof

    :ProfessionalEducation
    set "sku=164"
    set "pidkey=8PTT6-RNW4C-6V7J2-C2D3X-MHBPB"
    set "License=Retail"
    set "skus=ProfessionalEducation"
    goto :eof

    :ProfessionalEducationN
    set "sku=165"
    set "pidkey=GJTYN-HDMQY-FRR76-HVGC7-QPF8P"
    set "License=Retail"
    set "skus=ProfessionalEducationN"
    goto :eof

    :ProfessionalWorkstation
    set "sku=161"
    set "pidkey=DXG7C-N36C4-C4HTG-X4T3X-2YV77"
    set "License=Retail"
    set "skus=ProfessionalWorkstation"
    goto :eof

    :ProfessionalWorkstationN
    set "sku=162"
    set "pidkey=WYPNQ-8C467-V2W6J-TX4WX-WT2RQ"
    set "License=Retail"
    set "skus=ProfessionalWorkstationN"
    goto :eof

    :Education
    set "sku=121"
    set "pidkey=YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY"
    set "License=Retail"
    set "skus=Education"
    goto :eof

    :EducationN
    set "sku=122"
    set "pidkey=84NGF-MHBT6-FXBX8-QWJK7-DRR8H"
    set "License=Retail"
    set "skus=EducationN"
    goto :eof

    :Enterprise
    set "sku=4"
    set "pidkey=XGVPP-NMH47-7TTHJ-W3FW7-8HV2C"
    set "License=OEM:NONSLP"
    set "skus=Enterprise"
    goto :eof

    :EnterpriseN
    set "sku=27"
    set "pidkey=YHMNQ-PPQW2-P8PGP-32643-C372T"
    set "License=Volume:MAK"
    set "skus=EnterpriseN"
    goto :eof

    :EnterpriseS
    if "%version%" equ "17763" (
    set "sku=125"
    set "pidkey=M7XTQ-FN8P6-TTKYV-9D4CC-J462D"
    set "License=Volume:GVLK"
    set "skus=EnterpriseS"
    goto :eof
      )
    if "%version%" geq "14393" (
    if "%version%" leq "17134" (
    set "sku=125"
    set "pidkey=NK96Y-D9CD8-W44CQ-R8YTK-DYJWX"
    set "License=Retail"
    set "skus=EnterpriseS"
    goto :eof
    ) else (
    goto end
      )
      )

    :EnterpriseSN
    if "%version%" equ "17763" (
    set "sku=126"
    set "pidkey=92NFX-8DJQP-P6BBQ-THF9C-7CG2H"
    set "License=Volume:GVLK"
    set "skus=EnterpriseSN"
    goto :eof
      )
    if "%version%" geq "14393" (
    if "%version%" leq "17134" (
    set "sku=126"
    set "pidkey=C73T8-FNJRG-FTQWK-2JP2R-VMJWR"
    set "License=Retail"
    set "skus=EnterpriseSN"
    goto :eof
    ) else (
    goto end
      )
      )

    :IoTEnterprise
    if "%version%" geq "18362" (
    set "sku=188"
    set "pidkey=XQQYW-NFFMW-XJPBH-K8732-CKFFD"
    set "License=OEM:NONSLP"
    set "skus=IoTEnterprise"
    goto :eof
    ) else (
    goto end
      )

    :ServerRdsh
    if "%version%" geq "17134" (
    set "sku=175"
    set "pidkey=NJCF7-PW8QT-3324D-688JX-2YV66"
    set "License=Retail"
    set "skus=ServerRdsh"
    goto :eof
    ) else (
    goto end
      )

    :ServerDatacenter
    if "%version%" equ "17763" (
    set "sku=8"
    set "pidkey=WMDGN-G9PQG-XVVXX-R3X43-63DFG"
    set "License=Volume:GVLK"
    set "skus=ServerDatacenter"
    goto :eof
    ) else if "%version%" equ "14393" (
    set "sku=8"
    set "pidkey=CB7KF-BWN84-R7R2Y-793K2-8XDDG"
    set "License=Volume:GVLK"
    set "skus=ServerDatacenter"
    goto :eof
      )
    goto end

    :ServerStandard
    if "%version%" equ "17763" (
    set "sku=7"
    set "pidkey=N69G4-B89J2-4G8F4-WWYCC-J464C"
    set "License=Volume:GVLK"
    set "skus=ServerStandard"
    goto :eof
    ) else if "%version%" equ "14393" (
    set "sku=7"
    set "pidkey=WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY"
    set "License=Volume:GVLK"
    set "skus=ServerStandard"
    goto :eof
      )
    goto end
