@echo off :: For unattended mode, run the script with /u parameter. ::======================================================================================================================================== : ================================================================= : This script is a part of 'Microsoft Activation Scripts' : Maintained by @WindowsAddict : Homepage - https://www.nsaneforums.com/topic/316668--/ : ================================================================= ::======================================================================================================================================== ::======================================================================================================================================== cls title Install Windows 10 Retail_OEM Key if /i "%*" EQU "/u" (set Unattended=1) else (set Unattended=0) for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set "nul=>nul 2>&1" set "ELine=echo. &echo ==== ERROR ==== &echo." setlocal EnableDelayedExpansion ::======================================================================================================================================== : =========================================================== : Check if the file path name contains special characters : https://stackoverflow.com/a/33626625 : Written by @jeb (stackoverflow) : Thanks to @abbodi1406 (MDL) for the help. : =========================================================== setlocal setlocal DisableDelayedExpansion set "param=%~f0" cmd /v:on /c echo(^^!param^^!| findstr /R "[| ` ~ ! @ %% \^ & ( ) \[ \] { } + = ; ' , |]*^" endlocal if %errorlevel% EQU 0 ( %ELine% echo Disallowed special characters detected in file path name. echo Make sure file path name do not have following special characters, echo ^` ^~ ^! ^@ %% ^^ ^& ^( ^) [ ] { } ^+ ^= ^; ^' ^, goto Done ) ::======================================================================================================================================== if %winbuild% LSS 10240 ( %ELine% echo Unsupported OS version Detected. echo Project is supported only for Windows 10. goto Done ) ::======================================================================================================================================== : ================================================ : Self-elevate passing args and preventing loop : Written by @AveYo aka @BAU : ================================================ reg query HKEY_USERS\S-1-5-20 1>nul 2>nul && goto GotPrivileges If "%ElevError%"=="Y" goto Elev_Err set "args="%~f0" %*" & call set "args=%%args:"=\"%%" echo Initializing... powershell -c "start cmd -ArgumentList '/c set ElevError=Y& call %args%' -verb runas" && exit /b :Elev_Err %ELine% echo Right click on this file and select 'Run as administrator' goto Done :GotPrivileges ::======================================================================================================================================== mode con: cols=98 lines=30 FOR /F "TOKENS=2 DELIMS==" %%A IN ('"WMIC PATH SoftwareLicensingProduct WHERE (Name LIKE 'Windows%%' AND PartialProductKey is not NULL) GET LicenseFamily /VALUE"') DO IF NOT ERRORLEVEL 1 SET "osedition=%%A" if not defined osedition (FOR /F "TOKENS=3 DELIMS=: " %%A IN ('DISM /English /Online /Get-CurrentEdition 2^>nul ^| FIND /I "Current Edition :"') DO SET "osedition=%%A") cls if "%osedition%"=="" ( %ELine% echo OS Edition was not detected properly. Aborting... goto Done ) cls set key= call :%osedition% %nul% if "%Key%"=="" ( %ELine% echo [%osedition% ^| %winbuild%] Digital License ^(HWID^) Activation is Not Supported. goto Done ) ::======================================================================================================================================== if %Unattended% EQU 1 goto ContinueKeyInsert cls echo -------------------------------------------------------------------------------------------------- echo Install [%osedition% ^| %winbuild%] Retail_OEM_Key %key% echo -------------------------------------------------------------------------------------------------- echo. choice /C:AB /N /M "[A] Continue [B] Exit : " if errorlevel 2 exit /b if errorlevel 1 goto ContinueKeyInsert :ContinueKeyInsert cls echo ----------------------------------------------------------------- echo. echo Installing [%osedition% ^| %winbuild%] Retail_OEM_Key echo. cscript /nologo %windir%\system32\slmgr.vbs -ipk %key% echo ----------------------------------------------------------------- goto Done ::======================================================================================================================================== :: Retail_OEM Key List :Core set "key=YTMG3-N6DKC-DKB77-7M9GH-8HVX7" exit /b :CoreCountrySpecific set "key=N2434-X9D7W-8PF6X-8DV9T-8TYMD" exit /b :CoreN set "key=4CPRK-NM3K3-X6XXQ-RXX86-WXCHW" exit /b :CoreSingleLanguage set "key=BT79Q-G7N6G-PGBYW-4YWX6-6F4BT" exit /b :Education set "key=YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY" exit /b :EducationN set "key=84NGF-MHBT6-FXBX8-QWJK7-DRR8H" exit /b :Enterprise set "key=XGVPP-NMH47-7TTHJ-W3FW7-8HV2C" exit /b :EnterpriseN set "key=3V6Q6-NQXCX-V8YXR-9QCYV-QPFCT" exit /b :EnterpriseS if "%winbuild%" EQU "10240" set "key=FWN7H-PF93Q-4GGP8-M8RF3-MDWWW" if "%winbuild%" EQU "14393" set "key=NK96Y-D9CD8-W44CQ-R8YTK-DYJWX" exit /b :EnterpriseSN if "%winbuild%" EQU "10240" set "key=8V8WN-3GXBH-2TCMG-XHRX3-9766K" if "%winbuild%" EQU "14393" set "key=2DBW3-N2PJG-MVHW3-G7TDK-9HKR4" exit /b :Professional set "key=VK7JG-NPHTM-C97JM-9MPGT-3V66T" exit /b :ProfessionalEducation set "key=8PTT6-RNW4C-6V7J2-C2D3X-MHBPB" exit /b :ProfessionalEducationN set "key=GJTYN-HDMQY-FRR76-HVGC7-QPF8P" exit /b :ProfessionalN set "key=2B87N-8KFHP-DKV6R-Y2C8J-PKCKT" exit /b :ProfessionalWorkstation set "key=DXG7C-N36C4-C4HTG-X4T3X-2YV77" exit /b :ProfessionalWorkstationN set "key=WYPNQ-8C467-V2W6J-TX4WX-WT2RQ" exit /b :ServerRdsh set "key=NJCF7-PW8QT-3324D-688JX-2YV66" exit /b ::======================================================================================================================================== :Done echo. if %Unattended% EQU 1 ( echo Exiting in 5 seconds... if %winbuild% LSS 7600 (ping -n 5 127.0.0.1 > nul) else (timeout /t 5) exit /b ) echo Press any key to exit... pause >nul exit /b ::========================================================================================================================================