Added HWID support for Windows 10 LTSC 2019
- Now Microsoft support HWID (Digital License) for Windows 10 LTSC 2019, added key for it in the script. - Some minor improvements.
This commit is contained in:
		| @@ -0,0 +1,6 @@ | ||||
| [{000214A0-0000-0000-C000-000000000046}] | ||||
| Prop3=19,11 | ||||
| [InternetShortcut] | ||||
| IDList= | ||||
| URL=https://pastebin.com/raw/jduBSazJ | ||||
| HotKey=0 | ||||
| @@ -0,0 +1,621 @@ | ||||
| @setlocal DisableDelayedExpansion | ||||
| @echo off | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| :: ======================================================================================================= | ||||
| :: | ||||
| ::   This script is a part of 'Microsoft Activation Scripts' project. | ||||
| :: | ||||
| ::   Homepages- | ||||
| ::   NsaneForums: (Login Required) https://www.nsaneforums.com/topic/316668-microsoft-activation-scripts/ | ||||
| ::   GitHub: https://github.com/massgravel/Microsoft-Activation-Scripts | ||||
| ::   GitLab: https://gitlab.com/massgrave/microsoft-activation-scripts | ||||
| :: | ||||
| ::   Maintained by @WindowsAddict | ||||
| :: | ||||
| :: ======================================================================================================= | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| cls | ||||
| title Extract $OEM$ Folder | ||||
| for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G | ||||
| set "_psc=powershell" | ||||
| set "nul=1>nul 2>nul" | ||||
| set "EchoRed=%_psc% write-host -back Black -fore Red" | ||||
| set "EchoGreen=%_psc% write-host -back Black -fore Green" | ||||
| set "ELine=echo: & %EchoRed% ==== ERROR ==== &echo:" | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| for %%i in (powershell.exe) do if "%%~$path:i"=="" ( | ||||
| echo: &echo ==== ERROR ==== &echo: | ||||
| echo Powershell is not installed in the system. | ||||
| echo Aborting... | ||||
| goto Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| if %winbuild% LSS 7600 ( | ||||
| %ELine% | ||||
| echo Unsupported OS version Detected. | ||||
| echo Project is supported only for Windows 7/8/8.1/10 and their Server equivalent. | ||||
| goto Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Fix for the special characters limitation in path name | ||||
| ::  Written by @abbodi1406 | ||||
|  | ||||
| set "_work=%~dp0" | ||||
| if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%" | ||||
|  | ||||
| set "_batf=%~f0" | ||||
| set "_batp=%_batf:'=''%" | ||||
|  | ||||
| setlocal EnableDelayedExpansion | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| mode con cols=98 lines=30 | ||||
|  | ||||
| ::  Get correct Desktop Location with powershell | ||||
| ::  Written by @dcshoecomp (superuser.com) | ||||
| ::  https://superuser.com/a/1413170 | ||||
|  | ||||
| for /f "delims=" %%a in ('%_psc% "& {write-host $([Environment]::GetFolderPath('Desktop'))}"') do Set "desktop=%%a" | ||||
|  | ||||
| if exist "%desktop%\$OEM$\" ( | ||||
| echo _____________________________________________________ | ||||
| %ELine% | ||||
| echo $OEM$ folder already exists on the Desktop. | ||||
| echo _____________________________________________________ | ||||
| goto Done2 | ||||
| ) | ||||
|  | ||||
| set "_dir=%desktop%\$OEM$\$$\Setup\Scripts" | ||||
| set _nofile= | ||||
|  | ||||
| set "_fdir1=Activators\HWID-KMS38_Activation" | ||||
| set "HWID_Activation.cmd=%_fdir1%\HWID_Activation.cmd" | ||||
| set "KMS38_Activation.cmd=%_fdir1%\KMS38_Activation.cmd" | ||||
| set "ClipUp.exe=%_fdir1%\BIN\ClipUp.exe" | ||||
| set "gatherosstate.exe=%_fdir1%\BIN\gatherosstate.exe" | ||||
| set "slc.dll=%_fdir1%\BIN\slc.dll" | ||||
| set "ARM64_gatherosstate.exe=%_fdir1%\BIN\ARM64_gatherosstate.exe" | ||||
| set "ARM64_slc.dll=%_fdir1%\BIN\ARM64_slc.dll" | ||||
|  | ||||
| set "_fdir2=Activators\Online_KMS_Activation" | ||||
| set "Activate.cmd=%_fdir2%\Activate.cmd" | ||||
| set "Renewal_Setup.cmd=%_fdir2%\Renewal_Setup.cmd" | ||||
| set "cleanosppx64.exe=%_fdir2%\BIN\cleanosppx64.exe" | ||||
| set "cleanosppx86.exe=%_fdir2%\BIN\cleanosppx86.exe" | ||||
|  | ||||
| cd /d "!_work!" | ||||
| pushd "!_work!" | ||||
| cd .. | ||||
| cd .. | ||||
|  | ||||
| if not exist "%HWID_Activation.cmd%" set _nofile=1 | ||||
| if not exist "%KMS38_Activation.cmd%" set _nofile=1 | ||||
| if not exist "%ClipUp.exe%" set _nofile=1 | ||||
| if not exist "%gatherosstate.exe%" set _nofile=1 | ||||
| if not exist "%slc.dll%" set _nofile=1 | ||||
| if not exist "%ARM64_gatherosstate.exe%" set _nofile=1 | ||||
| if not exist "%ARM64_slc.dll%" set _nofile=1 | ||||
|  | ||||
| if not exist "%Activate.cmd%" set _nofile=1 | ||||
| if not exist "%Renewal_Setup.cmd%" set _nofile=1 | ||||
| if not exist "%cleanosppx64.exe%" set _nofile=1 | ||||
| if not exist "%cleanosppx86.exe%" set _nofile=1 | ||||
|  | ||||
| if defined _nofile ( | ||||
| echo _____________________________________________________ | ||||
| %ELine% | ||||
| echo Some files are missing in the 'Activators' folder. | ||||
| echo _____________________________________________________ | ||||
| goto Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :Menu | ||||
|  | ||||
| cls | ||||
| echo: | ||||
| echo: | ||||
| echo                             Extract the $OEM$ Folder on your desktop. | ||||
| echo                                  For more details use Read me. | ||||
| echo                       _______________________________________________________ | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|   [1] HWID                                            ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|   [2] KMS38                                           ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|   [3] HWID, Fallback to KMS38                         ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|   [4] Online KMS                                      ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|   [5] HWID ^+ Online KMS                               ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|   [6] KMS38 ^+ Online KMS                              ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|   [7] HWID, Fallback to KMS38 ^+ Online KMS            ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|   [8] Exit                                            ^| | ||||
| echo                      ^|                                                       ^| | ||||
| echo                      ^|_______________________________________________________^| | ||||
| echo:      | ||||
| choice /C:12345678 /N /M ">                     Enter Your Choice [1,2,3,4,5,6,7,8] : " | ||||
|  | ||||
| if errorlevel 8 exit /b | ||||
| if errorlevel 7 goto:$OEM$HWID_FB_KMS38-KMS | ||||
| if errorlevel 6 goto:$OEM$KMS38KMS | ||||
| if errorlevel 5 goto:$OEM$HWIDKMS | ||||
| if errorlevel 4 goto:$OEM$KMS | ||||
| if errorlevel 3 goto:$OEM$HWID_FB_KMS38 | ||||
| if errorlevel 2 goto:$OEM$KMS38 | ||||
| if errorlevel 1 goto:$OEM$HWID | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :$OEM$HWID | ||||
|  | ||||
| cls | ||||
| call :Prep | ||||
| call :HWIDPrep | ||||
| call :export HWIDSetup "%_dir%\SetupComplete.cmd" | ||||
| set error_= | ||||
| call :HWIDPrep2 | ||||
|  | ||||
| if defined error_ goto ErrorFound | ||||
| set "_oem=HWID" | ||||
| goto Done | ||||
|  | ||||
| :HWIDSetup: | ||||
| @echo off | ||||
|  | ||||
| reg query HKU\S-1-5-19 1>nul 2>nul || ( | ||||
| echo ==== Error ==== | ||||
| echo Right click on this file and select 'Run as administrator' | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
| ) | ||||
|  | ||||
| call "%~dp0HWID_Activation.cmd" /u | ||||
|  | ||||
| cd /d "%SystemRoot%\Setup\" | ||||
| if exist "%SystemRoot%\Setup\Scripts\" @RD /S /Q "%SystemRoot%\Setup\Scripts\" | ||||
| exit /b | ||||
| :HWIDSetup: | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :$OEM$KMS38 | ||||
|  | ||||
| cls | ||||
| call :Prep | ||||
| call :KMS38Prep | ||||
| call :export KMS38Setup "%_dir%\SetupComplete.cmd" | ||||
| set error_= | ||||
| call :KMS38Prep2 | ||||
|  | ||||
| if defined error_ goto ErrorFound | ||||
| set "_oem=KMS38" | ||||
| goto Done | ||||
|  | ||||
| :KMS38Setup: | ||||
| @echo off | ||||
|  | ||||
| reg query HKU\S-1-5-19 1>nul 2>nul || ( | ||||
| echo ==== Error ==== | ||||
| echo Right click on this file and select 'Run as administrator' | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
| ) | ||||
|  | ||||
| call "%~dp0KMS38_Activation.cmd" /u | ||||
|  | ||||
| cd /d "%SystemRoot%\Setup\" | ||||
| if exist "%SystemRoot%\Setup\Scripts\" @RD /S /Q "%SystemRoot%\Setup\Scripts\" | ||||
| exit /b | ||||
| :KMS38Setup: | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :$OEM$HWID_FB_KMS38 | ||||
|  | ||||
| cls | ||||
| call :Prep | ||||
|  | ||||
| copy /y /b "%HWID_Activation.cmd%" "%_dir%\HWID_Activation.cmd" %nul% | ||||
| call :KMS38Prep | ||||
| call :export HWID_FB_KMS38 "%_dir%\SetupComplete.cmd" | ||||
|  | ||||
| set error_= | ||||
| If not exist "%_dir%\HWID_Activation.cmd" (set error_=1) | ||||
| call :KMS38Prep2 | ||||
|  | ||||
| if defined error_ goto ErrorFound | ||||
| set "_oem=HWID`, Fallback to KMS38" | ||||
| goto Done | ||||
|  | ||||
| :HWID_FB_KMS38: | ||||
| @echo off | ||||
|  | ||||
| setlocal EnableDelayedExpansion | ||||
| reg query HKU\S-1-5-19 1>nul 2>nul || ( | ||||
| echo ==== Error ==== | ||||
| echo Right click on this file and select 'Run as administrator' | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
| ) | ||||
|  | ||||
| for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G | ||||
|  | ||||
| ::  Check Windows Edition | ||||
| set osedition= | ||||
| for /f "tokens=2 delims==" %%a in ('"wmic path SoftwareLicensingProduct where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and PartialProductKey is not NULL) get LicenseFamily /VALUE" 2^>nul') 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" | ||||
|  | ||||
| ::  Check Installation type | ||||
| set instype= | ||||
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v InstallationType 2^>nul') do if not errorlevel 1 set "instype=%%b" | ||||
|  | ||||
| set KMS38= | ||||
| if "%winbuild%" GEQ "17763" if "%osedition%"=="EnterpriseS" set KMS38=1 | ||||
| if "%winbuild%" GEQ "17763" if "%osedition%"=="EnterpriseSN" set KMS38=1 | ||||
| if "%osedition%"=="EnterpriseG" set KMS38=1 | ||||
| if "%osedition%"=="EnterpriseGN" set KMS38=1 | ||||
| if not "%instype%"=="Client" echo %osedition%| findstr /I /B Server 1>nul && set KMS38=1 | ||||
|  | ||||
| if defined KMS38 ( | ||||
| call "%~dp0KMS38_Activation.cmd" /u | ||||
| ) else ( | ||||
| call "%~dp0HWID_Activation.cmd" /u | ||||
| ) | ||||
|  | ||||
| cd /d "%SystemRoot%\Setup\" | ||||
| if exist "%SystemRoot%\Setup\Scripts\" @RD /S /Q "%SystemRoot%\Setup\Scripts\" | ||||
| exit /b | ||||
| :HWID_FB_KMS38: | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :$OEM$KMS | ||||
|  | ||||
| cls | ||||
| call :Prep | ||||
| call :KMSPrep | ||||
| call :export KMSSetup "%_dir%\SetupComplete.cmd" | ||||
| set error_= | ||||
| call :KMSPrep2 | ||||
|  | ||||
| if defined error_ goto ErrorFound | ||||
| set "_oem=Online KMS" | ||||
| goto Done | ||||
|  | ||||
| :KMSSetup: | ||||
| @echo off | ||||
|  | ||||
| ============================================================================ | ||||
|  | ||||
| :: Change value from 1 to 0 to disable KMS Renewal And Activation Task | ||||
| set Renewal_And_Activation_Task=1 | ||||
|  | ||||
| :: Change value from 1 to 0 to disable KMS activation desktop context menu  | ||||
| set Desktop_context_menu=1 | ||||
|  | ||||
| ============================================================================ | ||||
|  | ||||
| reg query HKU\S-1-5-19 1>nul 2>nul || ( | ||||
| echo ==== Error ==== | ||||
| echo Right click on this file and select 'Run as administrator' | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
| ) | ||||
|  | ||||
| if %Renewal_And_Activation_Task% EQU 1 call "%~dp0Renewal_Setup.cmd" /rat | ||||
| if %Desktop_context_menu% EQU 1 call "%~dp0Renewal_Setup.cmd" /dcm | ||||
|  | ||||
| cd /d "%SystemRoot%\Setup\" | ||||
| if exist "%SystemRoot%\Setup\Scripts\" @RD /S /Q "%SystemRoot%\Setup\Scripts\" | ||||
| exit /b | ||||
| :KMSSetup: | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :$OEM$HWIDKMS | ||||
|  | ||||
| cls | ||||
| call :Prep | ||||
| call :HWIDPrep | ||||
| call :KMSPrep | ||||
|  | ||||
| call :export HWIDKMSSetup "%_dir%\SetupComplete.cmd" | ||||
|  | ||||
| set error_= | ||||
| call :HWIDPrep2 | ||||
| call :KMSPrep2 | ||||
|  | ||||
| if defined error_ goto ErrorFound | ||||
| set "_oem=HWID `+ Online KMS" | ||||
| goto Done | ||||
|  | ||||
| :HWIDKMSSetup: | ||||
| @echo off | ||||
|  | ||||
| ============================================================================ | ||||
|  | ||||
| :: Change value from 1 to 0 to disable KMS Renewal And Activation Task | ||||
| set Renewal_And_Activation_Task=1 | ||||
|  | ||||
| :: Change value from 1 to 0 to disable KMS activation desktop context menu  | ||||
| set Desktop_context_menu=1 | ||||
|  | ||||
| ============================================================================ | ||||
|  | ||||
| reg query HKU\S-1-5-19 1>nul 2>nul || ( | ||||
| echo ==== Error ==== | ||||
| echo Right click on this file and select 'Run as administrator' | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
| ) | ||||
|  | ||||
| call "%~dp0HWID_Activation.cmd" /u | ||||
| if defined HWIDAct set SkipWinAct=/swa | ||||
|  | ||||
| if %Renewal_And_Activation_Task% EQU 1 call "%~dp0Renewal_Setup.cmd" /rat %SkipWinAct% | ||||
| if %Desktop_context_menu% EQU 1 call "%~dp0Renewal_Setup.cmd" /dcm %SkipWinAct% | ||||
|  | ||||
| cd /d "%SystemRoot%\Setup\" | ||||
| if exist "%SystemRoot%\Setup\Scripts\" @RD /S /Q "%SystemRoot%\Setup\Scripts\" | ||||
| exit /b | ||||
| :HWIDKMSSetup: | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :$OEM$KMS38KMS | ||||
|  | ||||
| cls | ||||
| call :Prep | ||||
| call :KMS38Prep | ||||
| call :KMSPrep | ||||
| call :export KMS38KMSSetup "%_dir%\SetupComplete.cmd" | ||||
| set error_= | ||||
| call :KMS38Prep2 | ||||
| call :KMSPrep2 | ||||
|  | ||||
| if defined error_ goto ErrorFound | ||||
| set "_oem=KMS38 `+ Online KMS" | ||||
| goto Done | ||||
|  | ||||
| :KMS38KMSSetup: | ||||
| @echo off | ||||
|  | ||||
| ============================================================================ | ||||
|  | ||||
| :: Change value from 1 to 0 to disable KMS Renewal And Activation Task | ||||
| set Renewal_And_Activation_Task=1 | ||||
|  | ||||
| :: Change value from 1 to 0 to disable KMS activation desktop context menu  | ||||
| set Desktop_context_menu=1 | ||||
|  | ||||
| ============================================================================ | ||||
|  | ||||
| reg query HKU\S-1-5-19 1>nul 2>nul || ( | ||||
| echo ==== Error ==== | ||||
| echo Right click on this file and select 'Run as administrator' | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
| ) | ||||
|  | ||||
| call "%~dp0KMS38_Activation.cmd" /u | ||||
|  | ||||
| if %Renewal_And_Activation_Task% EQU 1 call "%~dp0Renewal_Setup.cmd" /rat | ||||
| if %Desktop_context_menu% EQU 1 call "%~dp0Renewal_Setup.cmd" /dcm | ||||
|  | ||||
| cd /d "%SystemRoot%\Setup\" | ||||
| if exist "%SystemRoot%\Setup\Scripts\" @RD /S /Q "%SystemRoot%\Setup\Scripts\" | ||||
| exit /b | ||||
| :KMS38KMSSetup: | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :$OEM$HWID_FB_KMS38-KMS | ||||
|  | ||||
| cls | ||||
| call :Prep | ||||
|  | ||||
| copy /y /b "%HWID_Activation.cmd%" "%_dir%\HWID_Activation.cmd" %nul% | ||||
| call :KMS38Prep | ||||
| call :KMSPrep | ||||
| call :export HWID_FB_KMS38-KMSSetup "%_dir%\SetupComplete.cmd" | ||||
|  | ||||
| set error_= | ||||
| If not exist "%_dir%\HWID_Activation.cmd" (set error_=1) | ||||
| call :KMS38Prep2 | ||||
| call :KMSPrep2 | ||||
|  | ||||
| if defined error_ goto ErrorFound | ||||
| set "_oem=HWID`, Fallback to KMS38 `+ Online KMS" | ||||
| goto Done | ||||
|  | ||||
| :HWID_FB_KMS38-KMSSetup: | ||||
| @echo off | ||||
|  | ||||
| ============================================================================ | ||||
|  | ||||
| :: Change value from 1 to 0 to disable KMS Renewal And Activation Task | ||||
| set Renewal_And_Activation_Task=1 | ||||
|  | ||||
| :: Change value from 1 to 0 to disable KMS activation desktop context menu  | ||||
| set Desktop_context_menu=1 | ||||
|  | ||||
| ============================================================================ | ||||
|  | ||||
| setlocal EnableDelayedExpansion | ||||
| reg query HKU\S-1-5-19 1>nul 2>nul || ( | ||||
| echo ==== Error ==== | ||||
| echo Right click on this file and select 'Run as administrator' | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
| ) | ||||
|  | ||||
| for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G | ||||
|  | ||||
| ::  Check Windows Edition | ||||
| set osedition= | ||||
| for /f "tokens=2 delims==" %%a in ('"wmic path SoftwareLicensingProduct where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and PartialProductKey is not NULL) get LicenseFamily /VALUE" 2^>nul') 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" | ||||
|  | ||||
| ::  Check Installation type | ||||
| set instype= | ||||
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v InstallationType 2^>nul') do if not errorlevel 1 set "instype=%%b" | ||||
|  | ||||
| set KMS38= | ||||
| if "%winbuild%" GEQ "17763" if "%osedition%"=="EnterpriseS" set KMS38=1 | ||||
| if "%winbuild%" GEQ "17763" if "%osedition%"=="EnterpriseSN" set KMS38=1 | ||||
| if "%osedition%"=="EnterpriseG" set KMS38=1 | ||||
| if "%osedition%"=="EnterpriseGN" set KMS38=1 | ||||
| if not "%instype%"=="Client" echo %osedition%| findstr /I /B Server 1>nul && set KMS38=1 | ||||
|  | ||||
| if defined KMS38 ( | ||||
| call "%~dp0KMS38_Activation.cmd" /u | ||||
| ) else ( | ||||
| call "%~dp0HWID_Activation.cmd" /u | ||||
| if defined HWIDAct set SkipWinAct=/swa | ||||
| ) | ||||
|  | ||||
| if %Renewal_And_Activation_Task% EQU 1 call "%~dp0Renewal_Setup.cmd" /rat %SkipWinAct% | ||||
| if %Desktop_context_menu% EQU 1 call "%~dp0Renewal_Setup.cmd" /dcm %SkipWinAct% | ||||
|  | ||||
| cd /d "%SystemRoot%\Setup\" | ||||
| if exist "%SystemRoot%\Setup\Scripts\" @RD /S /Q "%SystemRoot%\Setup\Scripts\" | ||||
| exit /b | ||||
| :HWID_FB_KMS38-KMSSetup: | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :ErrorFound | ||||
|  | ||||
| %ELine% | ||||
| echo $OEM$ Folder was not created successfully... | ||||
| goto :Done2 | ||||
| :Done | ||||
| echo ________________________________________________________________________________________________ | ||||
| echo: | ||||
| %EchoGreen% %_oem% `$OEM`$ folder is successfully created on the Desktop. | ||||
| echo ________________________________________________________________________________________________ | ||||
| :Done2 | ||||
| echo: | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :Prep | ||||
|  | ||||
| cd /d "%desktop%" | ||||
| md "%desktop%\$OEM$\$$\Setup\Scripts\" | ||||
| md "%desktop%\$OEM$\$$\Setup\Scripts\BIN" | ||||
|  | ||||
| cd /d "!_work!" | ||||
| pushd "!_work!" | ||||
| cd .. | ||||
| cd .. | ||||
|  | ||||
| exit /b | ||||
|  | ||||
| :HWIDPrep | ||||
|  | ||||
| copy /y /b "%HWID_Activation.cmd%" "%_dir%\HWID_Activation.cmd" %nul% | ||||
| copy /y /b "%gatherosstate.exe%" "%_dir%\BIN\gatherosstate.exe" %nul% | ||||
| copy /y /b "%slc.dll%" "%_dir%\BIN\slc.dll" %nul% | ||||
| copy /y /b "%ARM64_gatherosstate.exe%" "%_dir%\BIN\ARM64_gatherosstate.exe" %nul% | ||||
| copy /y /b "%ARM64_slc.dll%" "%_dir%\BIN\ARM64_slc.dll" %nul% | ||||
| exit /b | ||||
|  | ||||
| :KMS38Prep | ||||
|  | ||||
| copy /y /b "%KMS38_Activation.cmd%" "%_dir%\KMS38_Activation.cmd" %nul% | ||||
| copy /y /b "%ClipUp.exe%" "%_dir%\BIN\ClipUp.exe" %nul% | ||||
| copy /y /b "%gatherosstate.exe%" "%_dir%\BIN\gatherosstate.exe" %nul% | ||||
| copy /y /b "%slc.dll%" "%_dir%\BIN\slc.dll" %nul% | ||||
| copy /y /b "%ARM64_gatherosstate.exe%" "%_dir%\BIN\ARM64_gatherosstate.exe" %nul% | ||||
| copy /y /b "%ARM64_slc.dll%" "%_dir%\BIN\ARM64_slc.dll" %nul% | ||||
| exit /b | ||||
|  | ||||
| :KMSPrep | ||||
|  | ||||
| copy /y /b "%Activate.cmd%" "%_dir%\Activate.cmd" %nul% | ||||
| copy /y /b "%Renewal_Setup.cmd%" "%_dir%\Renewal_Setup.cmd" %nul% | ||||
| copy /y /b "%cleanosppx64.exe%" "%_dir%\BIN\cleanosppx64.exe" %nul% | ||||
| copy /y /b "%cleanosppx86.exe%" "%_dir%\BIN\cleanosppx86.exe" %nul% | ||||
| exit /b | ||||
|  | ||||
| :HWIDPrep2 | ||||
|  | ||||
| If not exist "%_dir%\HWID_Activation.cmd" (set error_=1) | ||||
| If not exist "%_dir%\BIN\gatherosstate.exe" (set error_=1) | ||||
| If not exist "%_dir%\BIN\slc.dll" (set error_=1) | ||||
| If not exist "%_dir%\BIN\ARM64_gatherosstate.exe" (set error_=1) | ||||
| If not exist "%_dir%\BIN\ARM64_slc.dll" (set error_=1) | ||||
| If not exist "%_dir%\SetupComplete.cmd" (set error_=1) | ||||
| exit /b | ||||
|  | ||||
| :KMS38Prep2 | ||||
|  | ||||
| If not exist "%_dir%\KMS38_Activation.cmd" (set error_=1) | ||||
| If not exist "%_dir%\BIN\ClipUp.exe" (set error_=1) | ||||
| If not exist "%_dir%\BIN\gatherosstate.exe" (set error_=1) | ||||
| If not exist "%_dir%\BIN\slc.dll" (set error_=1) | ||||
| If not exist "%_dir%\BIN\ARM64_gatherosstate.exe" (set error_=1) | ||||
| If not exist "%_dir%\BIN\ARM64_slc.dll" (set error_=1) | ||||
| If not exist "%_dir%\SetupComplete.cmd" (set error_=1) | ||||
| exit /b | ||||
|  | ||||
| :KMSPrep2 | ||||
|  | ||||
| If not exist "%_dir%\Activate.cmd" (set error_=1) | ||||
| If not exist "%_dir%\Renewal_Setup.cmd" (set error_=1) | ||||
| If not exist "%_dir%\BIN\cleanosppx64.exe" (set error_=1) | ||||
| If not exist "%_dir%\BIN\cleanosppx86.exe" (set error_=1) | ||||
| If not exist "%_dir%\SetupComplete.cmd" (set error_=1) | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Extract the text from batch script without character and file encoding issue | ||||
| ::  Thanks to @abbodi1406 | ||||
|  | ||||
| :export | ||||
| %nul% %_psc% "$f=[io.file]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('%~2',$f[1].Trim(),[System.Text.Encoding]::ASCII);" &exit/b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
| @@ -0,0 +1,123 @@ | ||||
| ==================================================================================================== | ||||
|    $OEM$ Folders [Windows Pre-Activation]: | ||||
| ==================================================================================================== | ||||
|  | ||||
|  - To create a Preactivated Windows installation .iso, do the following things: | ||||
|    Copy the "$OEM$" folder to the "sources" folder in the Windows installation media (.iso or USB). | ||||
|    The directory will appear like this: \sources\$OEM$ in your altered .iso or on your bootable  | ||||
|    USB drive. | ||||
|    Now use this .iso or bootable USB drive to install Windows and it will either already be activated  | ||||
|    (KMS38) as soon as it boots, or will self-activate at first internet contact.  | ||||
|  | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|    HWID: | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|  | ||||
|  - When using Digital License (HWID), no files are stored on the system, and when connected to the  | ||||
|    internet for the first time, the system will self-activate at that time. | ||||
|     | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|    KMS38: | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|  | ||||
|  - When using KMS38, no files are stored on the system, and Windows becomes activated immediately  | ||||
|    without further actions or connectivity of any kind being required. | ||||
|  | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|    Online KMS (separately, or in combination with HWID or KMS38): | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|  | ||||
|  - It creates the following 2 Activation/Renewal Methods. You can turn off any of them in  | ||||
|    setupcomplete.cmd file | ||||
|  | ||||
|    ---------------------------------------------------------- | ||||
|  | ||||
|    1- Automatic Renewal via Task Scheduler--- | ||||
|  | ||||
|    It creates following files and tasks, | ||||
|  | ||||
|    Files: | ||||
|    C:\ProgramData\Online_KMS_Activation\BIN\cleanosppx64.exe | ||||
|    C:\ProgramData\Online_KMS_Activation\BIN\cleanosppx86.exe | ||||
|    C:\ProgramData\Online_KMS_Activation\Activate.cmd | ||||
|    C:\ProgramData\Online_KMS_Activation\Info.txt | ||||
|  | ||||
|    Scheduled Tasks: | ||||
|    \Online_KMS_Activation_Script-Renewal  (Weekly) | ||||
|    \Online_KMS_Activation_Script-Run_Once (Activation Task) | ||||
|  | ||||
|    The scheduled task runs only if the system is connected to the Internet. | ||||
|    Activation Task will run on the system login and after successful activation and registering  | ||||
|    online KMS server, this task will delete itself. leaving behind only one task to run weekly  | ||||
|    for the lifetime of the system.  | ||||
|  | ||||
|    ---------------------------------------------------------- | ||||
|     | ||||
|    2- Manual Renewal via Desktop Context Menu--- | ||||
|  | ||||
|    It creates Desktop context Menu for manual activation and renewal. | ||||
|    It creates the following files and registry entries. | ||||
|  | ||||
|    Files: | ||||
|    C:\ProgramData\Online_KMS_Activation\BIN\cleanosppx64.exe | ||||
|    C:\ProgramData\Online_KMS_Activation\BIN\cleanosppx86.exe | ||||
|    C:\ProgramData\Online_KMS_Activation\Activate.cmd | ||||
|    C:\ProgramData\Online_KMS_Activation\Info.txt | ||||
|     | ||||
|    Registry entries: | ||||
|    HKCR\DesktopBackground\shell\Activate Windows - Office | ||||
|    HKCR\DesktopBackground\shell\Activate Windows - Office\command | ||||
|  | ||||
|    It creates an easy to reach the Desktop context menu for the manual activation renewal. | ||||
|     | ||||
|    ---------------------------------------------------------- | ||||
|  | ||||
|    d30a0e4e5911d3ca705617d17225372731c770e2 *cleanosppx64.exe                   Virus Total = 0/66 | ||||
|    39ed8659e7ca16aaccb86def94ce6cec4c847dd6 *cleanosppx86.exe                   Virus Total = 1/66 | ||||
|  | ||||
|    Virus Total Report Date: 12-11-2019 | ||||
|     | ||||
|    These files are official Microsoft files and in this script, these are used in  | ||||
|    cleaning office license in C2R Retail office to VL conversion process. | ||||
|     | ||||
|    The source of these files is the 'old' version of Microsoft Tool O15CTRRemove.diagcab | ||||
|    You can get the original file here https://s.put.re/WFuXpyWA.zip | ||||
|  | ||||
|    ---------------------------------------------------------- | ||||
|     | ||||
|    IMPORTANT NOTE - Some sensitive AV's may flag the Automatic Renewal via the Task, and not  | ||||
|    because of KMS, because for them it's suspicious to run long scripts in the background as Tasks. | ||||
|  | ||||
|    It's recommended to set exclusions in Antivirus for | ||||
|    C:\ProgramData\Online_KMS_Activation\Activate.cmd | ||||
|  | ||||
|    ---------------------------------------------------------- | ||||
|     | ||||
|  - When using Online KMS plus HWID Digital License, Online KMS script will be set to skip Windows  | ||||
|    activation (if the HWID activation was applied but was not successful due to lack of internet  | ||||
|    at the time of installation of Windows) but will register the KMS for other products, and all  | ||||
|    later installed Volume License (VL) products (MS Office) will self-activate when going online.  | ||||
|  | ||||
|  - When using Online KMS plus KMS38, Online KMS will not skip Windows activation but skip KMS38  | ||||
|    activation and will register the KMS for other products, and all subsequently-installed Volume  | ||||
|    License (VL) products (MS Office) will self-activate when going online. | ||||
|  | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|    HWID (Fallback to KMS38): | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|    | ||||
|  - In this method, KMS38 will be used for the activation in case the Windows version is not  | ||||
|    supported by HWID. For example, Windows 10 LTSC and Windows server. | ||||
|  | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|    Activation Type       Supported Product             Activation Period | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|     | ||||
|    Digital License    -  Windows 10                 -  Permanent | ||||
|    KMS38              -  Windows 10 / Server        -  Until the year 2038 | ||||
|    Online KMS         -  Windows / Server / Office  -  For 180 Days, renewal task needs to be  | ||||
|                                                        created for lifetime auto-activation. | ||||
|     | ||||
| ---------------------------------------------------------------------------------------------------- | ||||
|     | ||||
|    * For more details, use the ReadMe.txt included in the respective activation folders. | ||||
| @@ -0,0 +1,412 @@ | ||||
| @setlocal DisableDelayedExpansion | ||||
| @echo off | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| :: ======================================================================================================= | ||||
| :: | ||||
| ::   This script is a part of 'Microsoft Activation Scripts' project. | ||||
| :: | ||||
| ::   Homepages- | ||||
| ::   NsaneForums: (Login Required) https://www.nsaneforums.com/topic/316668-microsoft-activation-scripts/ | ||||
| ::   GitHub: https://github.com/massgravel/Microsoft-Activation-Scripts | ||||
| ::   GitLab: https://gitlab.com/massgrave/microsoft-activation-scripts | ||||
| :: | ||||
| ::   Maintained by @WindowsAddict | ||||
| :: | ||||
| :: ======================================================================================================= | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| title Protect / Unprotect KMS38 Activation | ||||
| set _elev= | ||||
| if /i "%~1"=="-el" set _elev=1 | ||||
| for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G | ||||
| set "_psc=powershell" | ||||
| set "nul=1>nul 2>nul" | ||||
| set "Red="white" "DarkRed"" | ||||
| set "Green="white" "DarkGreen"" | ||||
| set "Magenta="white" "darkmagenta"" | ||||
| set "Gray="white" "darkgray"" | ||||
| set "Black="white" "Black"" | ||||
| set "ELine=echo: &call :PU_color "==== ERROR ====" %Red% &echo:" | ||||
| set line=__________________________________________________________________________________________________ | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| for %%i in (powershell.exe) do if "%%~$path:i"=="" ( | ||||
| echo: &echo ==== ERROR ==== &echo: | ||||
| echo Powershell is not installed in the system. | ||||
| echo Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| if %winbuild% LSS 14393 ( | ||||
| %ELine% | ||||
| echo Unsupported OS version Detected. | ||||
| echo Project is supported only for Windows 10 / Server 1607 [14393] and later builds. | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Elevate script as admin and pass arguments and preventing loop | ||||
| ::  Thanks to @hearywarlot [ https://forums.mydigitallife.net/threads/.74332/ ] for the VBS method. | ||||
| ::  Thanks to @abbodi1406 for the powershell method and solving special characters issue in file path name. | ||||
|  | ||||
| %nul% reg query HKU\S-1-5-19 && ( | ||||
|   goto :Passed | ||||
|   ) || ( | ||||
|   if defined _elev goto :E_Admin | ||||
| ) | ||||
|  | ||||
| set "_batf=%~f0" | ||||
| set "_vbsf=%temp%\admin.vbs" | ||||
| set _PSarg="""%~f0""" -el | ||||
|  | ||||
| setlocal EnableDelayedExpansion | ||||
|  | ||||
| ( | ||||
| echo Set strArg=WScript.Arguments.Named | ||||
| echo Set strRdlproc = CreateObject^("WScript.Shell"^).Exec^("rundll32 kernel32,Sleep"^) | ||||
| echo With GetObject^("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" ^& strRdlproc.ProcessId ^& "'"^) | ||||
| echo With GetObject^("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" ^& .ParentProcessId ^& "'"^) | ||||
| echo If InStr ^(.CommandLine, WScript.ScriptName^) ^<^> 0 Then | ||||
| echo strLine = Mid^(.CommandLine, InStr^(.CommandLine , "/File:"^) + Len^(strArg^("File"^)^) + 8^) | ||||
| echo End If | ||||
| echo End With | ||||
| echo .Terminate | ||||
| echo End With | ||||
| echo CreateObject^("Shell.Application"^).ShellExecute "cmd.exe", "/c " ^& chr^(34^) ^& chr^(34^) ^& strArg^("File"^) ^& chr^(34^) ^& strLine ^& chr^(34^), "", "runas", 1 | ||||
| )>"!_vbsf!" | ||||
|  | ||||
| (%nul% cscript //NoLogo "!_vbsf!" /File:"!_batf!" -el) && ( | ||||
| del /f /q "!_vbsf!" | ||||
| exit /b | ||||
| ) || ( | ||||
| del /f /q "!_vbsf!" | ||||
| %nul% %_psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && ( | ||||
| exit /b | ||||
| ) || ( | ||||
| goto :E_Admin | ||||
| ) | ||||
| ) | ||||
| exit /b | ||||
|  | ||||
| :E_Admin | ||||
| %ELine% | ||||
| echo This script require administrator privileges. | ||||
| echo To do so, right click on this script and select 'Run as administrator'. | ||||
| goto PU_Done | ||||
|  | ||||
| :Passed | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| mode con: cols=98 lines=30 | ||||
|  | ||||
| set slp=SoftwareLicensingProduct | ||||
| set sls=SoftwareLicensingService | ||||
| set wApp=55c92734-d682-4d71-983e-d6ec3f16059f | ||||
| set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" | ||||
|  | ||||
| ::  Fix for the special characters limitation in path name | ||||
| ::  Written by @abbodi1406 | ||||
|  | ||||
| set "_batf=%~f0" | ||||
| set "_batp=%_batf:'=''%" | ||||
|  | ||||
| setlocal EnableDelayedExpansion | ||||
|  | ||||
| ::  Check Windows OS name | ||||
|  | ||||
| set winos= | ||||
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName 2^>nul') do if not errorlevel 1 set "winos=%%b" | ||||
| if not defined winos for /f "tokens=2* delims== " %%a in ('"wmic os get caption /value" 2^>nul') do if not errorlevel 1 set "winos=%%b" | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| cls | ||||
| echo: | ||||
| echo %line% | ||||
| echo: | ||||
| echo    [1] Protect KMS38 Activation from being overwritten by 180 days KMS Activators | ||||
| echo:    | ||||
| echo    [2] Undo changes | ||||
| echo:    | ||||
| echo    [3] Exit | ||||
| echo: | ||||
| echo %line% | ||||
| echo: | ||||
| choice /C:123 /N /M ">  Enter Your Choice [1,2,3] : " | ||||
|  | ||||
| if errorlevel 3 exit /b | ||||
| if errorlevel 2 goto Undo | ||||
| if errorlevel 1 goto Protect | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :Protect | ||||
|  | ||||
| cls | ||||
|  | ||||
| ::  Check KMS client setup key | ||||
|  | ||||
| set _gvlk= | ||||
| wmic path %slp% where "ApplicationID='%wApp%' and PartialProductKey<>null" Get ProductKeyChannel 2>nul | findstr /i GVLK 1>nul && (set _gvlk=1) | ||||
|  | ||||
| if not defined _gvlk ( | ||||
| %ELine% | ||||
| echo System is not activated with KMS38. ^(KMS Key is not installed^)  Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::  Check Activation Grace Period | ||||
|  | ||||
| set gpr= | ||||
| for /f "tokens=2 delims==" %%# in ('"wmic path %slp% where (ApplicationID='%wApp%' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get GracePeriodRemaining /VALUE" ') do set "gpr=%%#" | ||||
|  | ||||
| if "%gpr%" LEQ "259200" ( | ||||
| %ELine% | ||||
| echo System is not activated with KMS38.  Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::  Check SKU value | ||||
|  | ||||
| set SKU= | ||||
| for /f "tokens=2 delims==" %%a IN ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" 2^>nul') do if not errorlevel 1 (set osSKU=%%a) | ||||
| if not defined SKU for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" /v OSProductPfn 2^>nul') do if not errorlevel 1 (set osSKU=%%a) | ||||
|  | ||||
| if "%osSKU%"=="" ( | ||||
| %ELine% | ||||
| echo SKU value was not detected properly. Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::  Check Windows Edition with SKU value for better accuracy | ||||
|  | ||||
| set osedition= | ||||
| call :K38_CheckEdition %nul% | ||||
|  | ||||
| if "%osedition%"=="" ( | ||||
| %ELine% | ||||
| echo OS Edition was not detected properly. Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::  Check Activation ID | ||||
|  | ||||
| set app= | ||||
| for /f "tokens=2 delims==" %%a in ('"wmic path %slp% where (ApplicationID='%wApp%' and LicenseFamily='%osedition%' and Description like '%%KMSCLIENT%%') get ID /VALUE" 2^>nul') do set "app=%%a" | ||||
|  | ||||
| if "%app%"=="" ( | ||||
| %ELine% | ||||
| echo Activation ID was not detected properly. Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| wmic path %sls% where __CLASS='%sls%' call ClearKeyManagementServiceMachine %nul% | ||||
| wmic path %sls% where __CLASS='%sls%' call ClearKeyManagementServicePort %nul% | ||||
|  | ||||
| reg query "HKLM\%SPPk%\%wApp%" %nul% && ( | ||||
| %nul% call :reg_takeownership "HKLM\%SPPk%\%wApp%" FullControl Allow S-1-5-32-544 | ||||
| reg delete "HKLM\%SPPk%\%wApp%" /f %nul% | ||||
| reg delete "HKU\S-1-5-20\%SPPk%\%wApp%" /f %nul% | ||||
| ) | ||||
|  | ||||
| reg query "HKLM\%SPPk%\%wApp%" %nul% && ( | ||||
| %ELine% | ||||
| echo Registry Key was not cleared successfully. Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::  Set specific KMS host to Local Host | ||||
| ::  Thanks to @abbodi1406 | ||||
|  | ||||
| set setkms_error= | ||||
|  | ||||
| wmic path %slp% where ID='%app%' call ClearKeyManagementServiceMachine %nul% || (set setkms_error=1) | ||||
| wmic path %slp% where ID='%app%' call ClearKeyManagementServicePort %nul% || (set setkms_error=1) | ||||
| wmic path %slp% where ID='%app%' call SetKeyManagementServiceMachine MachineName="127.0.0.2" %nul% || (set setkms_error=1) | ||||
| wmic path %slp% where ID='%app%' call SetKeyManagementServicePort 1688 %nul% || (set setkms_error=1) | ||||
|  | ||||
| if defined setkms_error ( | ||||
| reg delete "HKLM\%SPPk%\%wApp%" /f %nul% | ||||
| reg delete "HKU\S-1-5-20\%SPPk%\%wApp%" /f %nul% | ||||
| %ELine% | ||||
| echo Specific KMS host to Local Host was not properly applied. Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| %nul% call :reg_takeownership "HKLM\%SPPk%\%wApp%" "SetValue, Delete" Deny S-1-5-32-544 | ||||
|  | ||||
| reg delete "HKLM\%SPPk%\%wApp%" /f %nul% | ||||
| reg query "HKLM\%SPPk%\%wApp%" %nul% || ( | ||||
| %ELine% | ||||
| echo Registry Key was not protected properly. Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| ::  Check Activation Grace Period | ||||
|  | ||||
| set gpr= | ||||
| for /f "tokens=2 delims==" %%# in ('"wmic path %slp% where (ApplicationID='%wApp%' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL) get GracePeriodRemaining /VALUE" ') do set "gpr=%%#" | ||||
|  | ||||
| if "%gpr%" LEQ "259200" ( | ||||
| %ELine% | ||||
| echo System is not activated with KMS38. | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| cls | ||||
| echo: | ||||
| echo %line% | ||||
| echo: | ||||
| echo Specific KMS host set to 127.0.0.2 ^(Local Host^) successfully. | ||||
| echo: | ||||
| echo Registry item locked successfully. | ||||
| echo HKLM\%SPPk%\%wApp% | ||||
| echo: | ||||
| call :PU_color "%winos% - KMS38 Activation is now protected." %Green% | ||||
| echo: | ||||
| echo Now you need to activate Office with KMS ^(If required^) | ||||
| echo: | ||||
| echo %line% | ||||
|  | ||||
| goto PU_Done | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :Undo | ||||
|  | ||||
| cls | ||||
| set exist_= | ||||
| reg query "HKLM\%SPPk%\%wApp%" %nul% && (set exist_=1) | ||||
|  | ||||
| if defined exist_ ( | ||||
| %nul% call :reg_takeownership "HKLM\%SPPk%\%wApp%" FullControl Allow S-1-5-32-544 | ||||
| reg delete "HKLM\%SPPk%\%wApp%" /f %nul% | ||||
| reg delete "HKU\S-1-5-20\%SPPk%\%wApp%" /f %nul% | ||||
| ) | ||||
|  | ||||
| reg query "HKLM\%SPPk%\%wApp%" %nul% && ( | ||||
| %ELine% | ||||
| echo Registry Key was not cleared successfully. Aborting... | ||||
| goto PU_Done | ||||
| ) | ||||
|  | ||||
| echo: | ||||
| echo %line% | ||||
| echo: | ||||
| if defined exist_ ( | ||||
| echo Registry item deleted successfully. | ||||
| echo HKLM\%SPPk%\%wApp% | ||||
| echo: | ||||
| call :PU_color "KMS38 Activation is now unprotected [set to default]" %Green% | ||||
| ) else ( | ||||
| call :PU_color "It is already unprotected [set to default]" %Green% | ||||
| ) | ||||
| echo: | ||||
| echo %line% | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :PU_Done | ||||
| echo: | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :PU_color | ||||
|  | ||||
| %_psc% write-host '%1' -fore '%2' -back '%3' | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Check Windows Edition with SKU value for better accuracy | ||||
|  | ||||
| :K38_CheckEdition | ||||
|  | ||||
| for %%# in ( | ||||
| 4-Enterprise | ||||
| 7-ServerStandard | ||||
| 8-ServerDatacenter | ||||
| 27-EnterpriseN | ||||
| 48-Professional | ||||
| 49-ProfessionalN | ||||
| 50-ServerSolution | ||||
| 98-CoreN | ||||
| 99-CoreCountrySpecific | ||||
| 100-CoreSingleLanguage | ||||
| 101-Core | ||||
| 110-ServerCloudStorage | ||||
| 120-ServerARM64 | ||||
| 121-Education | ||||
| 122-EducationN | ||||
| 125-EnterpriseS | ||||
| 126-EnterpriseSN | ||||
| 145-ServerDatacenterACor | ||||
| 146-ServerStandardACor | ||||
| 161-ProfessionalWorkstation | ||||
| 162-ProfessionalWorkstationN | ||||
| 164-ProfessionalEducation | ||||
| 165-ProfessionalEducationN | ||||
| 168-ServerAzureCor | ||||
| 171-EnterpriseG | ||||
| 172-EnterpriseGN | ||||
| 175-ServerRdsh | ||||
| 183-CloudE | ||||
| ) do for /f "tokens=1,2 delims=-" %%A in ("%%#") do ( | ||||
| if %osSKU%==%%A set "osedition=%%B" | ||||
| ) | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Reg_takeownership snippet | ||||
| ::  Written by @AveYo aka @BAU | ||||
| ::  pastebin.com/XTPt0JSC | ||||
|  | ||||
| :reg_takeownership | ||||
| set "pargs=$regkey='%~1'; $p='%~2'; $a='%~3'; $u='%~4'; $o='%~5';" | ||||
| %_psc% "%pargs%; $f=[io.file]::ReadAllText('!_batp!') -split ':ps_reg_own\:.*';iex ($f[1]);" & exit/b:ps_reg_own: | ||||
| $dll0='[DllImport("ntdll.dll")]public static extern IntPtr RtlAdjustPrivilege(int a,bool b,bool c,ref bool d);'; | ||||
| $nt=Add-Type -Member $dll0 -Name Nt -PassThru; foreach($i in @(9,17,18)){$null=$nt::RtlAdjustPrivilege($i,1,0,[ref]0)} | ||||
| $root=$true; if($o -eq ''){$o=$u}; $rk=$regkey -split '\\',2; $key=$rk[1]; | ||||
| switch -regex ($rk[0]){ '[mM]'{$HK='LocalMachine'};'[uU]'{$HK='CurrentUser'};default{$HK='ClassesRoot'}; } | ||||
| $usr=0,0,0; $sec=0,0,0; $rule=0,0,0; $perm='FullControl',$p,$p; $access='Allow',$a,$a; $s=$o,$u,'S-1-5-32-544'; | ||||
| for($i=0;$i -le 2;$i++){ $usr[$i]=[System.Security.Principal.SecurityIdentifier]$s[$i]; | ||||
| $rule[$i]=[System.Security.AccessControl.RegistryAccessRule]::new($usr[$i], $perm[$i], 3, 0, $access[$i]); | ||||
| $sec[$i]=[System.Security.AccessControl.RegistrySecurity]::new(); } | ||||
| function Reg_TakeOwnership { param($hive, $key, $root=$false); | ||||
| $reg=[Microsoft.Win32.Registry]::$hive.OpenSubKey($key,'ReadWriteSubTree','TakeOwnership'); $sec[2].SetOwner($usr[2]); | ||||
| $reg.SetAccessControl($sec[2]); if($root){ $reg=$reg.OpenSubKey('','ReadWriteSubTree','ChangePermissions'); | ||||
| $acl=$reg.GetAccessControl(); $acl.SetAccessRuleProtection($false,$false); $acl.ResetAccessRule($rule[1]); | ||||
| $reg.SetAccessControl($acl); } $sec[0].SetOwner($usr[0]); $reg.SetAccessControl($sec[0]); } | ||||
| Reg_TakeOwnership $HK $key $true; if($root){ $r=[Microsoft.Win32.Registry]::$HK.OpenSubKey($key); | ||||
| foreach($sk in $r.GetSubKeyNames()){try{ Reg_TakeOwnership $HK "$($key+'\\'+$sk)" $false}catch{} }} | ||||
| Get-Acl "$($rk[0]+':\\'+$rk[1])" | fl:ps_reg_own: | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
| @@ -0,0 +1,48 @@ | ||||
| ==================================================================================================== | ||||
|    KMS38 Protection: | ||||
| ==================================================================================================== | ||||
|  | ||||
|  - If you don't know what KMS38 is, then first check it in the Read Me. | ||||
|  | ||||
|  - By default, a KMS38 Activation is vulnerable to unintended overwriting/replacement and  | ||||
|    neutralization by a 180-Day KMS Activator (non-KMS38 Activator). | ||||
|    However, with a few tricks you can ensure that no alternative KMS Activator can replace KMS38  | ||||
|    Activation by accident or even on purpose. This script demonstrate how to do/undo that. | ||||
|  | ||||
|  - Protect KMS38: | ||||
|    - How does KMS38 Protection work? | ||||
|      In the KMS activation method, the Windows Operating System first checks the KMS IP registered  | ||||
|      as a specific KMS, and if that is not defined then it checks the Global KMS IP. | ||||
|      Another fact is that if LocalHost (127.0.0.2) is defined as KMS IP in the Windows 8.1 and 10 OS's | ||||
|      then Windows will not accept it as a valid KMS IP. | ||||
|      This script simply utilizes the above facts to protect the KMS38 activation from being  | ||||
|      overwritten by any alternative 'normal' 180-Day KMS Activation. | ||||
|  | ||||
|      Script steps- | ||||
|      - Check if Windows is activated with KMS38, if yes, | ||||
|      - Set that Windows edition specific KMS IP to LocalHost (127.0.0.2), | ||||
| HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f\XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | ||||
| where X is Windows edition Activation ID. | ||||
|  | ||||
|      - Lock this Registry with Reg_takeownership snippet by @AveYo aka @BAU | ||||
|        pastebin.com/XTPt0JSC | ||||
|      - Done. | ||||
|  | ||||
|  - Unprotect KMS38: | ||||
|    - Just undo above steps, | ||||
|      - Give administrator full control of that mentioned registry key. | ||||
|      - Delete that registry key. | ||||
|      - Done. | ||||
|  | ||||
| ======================================================================================================= | ||||
|  | ||||
|   This script is a part of 'Microsoft Activation Scripts' project. | ||||
|  | ||||
|   Homepages- | ||||
|   NsaneForums: (Login Required) https://www.nsaneforums.com/topic/316668-microsoft-activation-scripts/ | ||||
|   GitHub: https://github.com/massgravel/Microsoft-Activation-Scripts | ||||
|   GitLab: https://gitlab.com/massgrave/microsoft-activation-scripts | ||||
|  | ||||
|   Maintained by @WindowsAddict | ||||
|  | ||||
| ======================================================================================================= | ||||
| @@ -0,0 +1,291 @@ | ||||
| @setlocal DisableDelayedExpansion | ||||
| @echo off | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| :: ======================================================================================================= | ||||
| :: | ||||
| ::   This script is a part of 'Microsoft Activation Scripts' project. | ||||
| :: | ||||
| ::   Homepages- | ||||
| ::   NsaneForums: (Login Required) https://www.nsaneforums.com/topic/316668-microsoft-activation-scripts/ | ||||
| ::   GitHub: https://github.com/massgravel/Microsoft-Activation-Scripts | ||||
| ::   GitLab: https://gitlab.com/massgrave/microsoft-activation-scripts | ||||
| :: | ||||
| ::   Maintained by @WindowsAddict | ||||
| :: | ||||
| :: ======================================================================================================= | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| cls | ||||
| title Change Windows 10 Edition with Retail/OEM Key | ||||
| set _elev= | ||||
| if /i "%~1"=="-el" set _elev=1 | ||||
| for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G | ||||
| set "_psc=powershell" | ||||
| set "nul=1>nul 2>nul" | ||||
| set "ELine=echo: &echo ==== ERROR ==== &echo:" | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| if %winbuild% LSS 17134 ( | ||||
| %ELine% | ||||
| echo Unsupported OS version Detected. | ||||
| echo OS Requirement - Windows 10 [17134] 1803 and later builds. | ||||
| goto Ced_Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Elevate script as admin and pass arguments and preventing loop | ||||
| ::  Thanks to @hearywarlot [ https://forums.mydigitallife.net/threads/.74332/ ] for the VBS method. | ||||
| ::  Thanks to @abbodi1406 for the powershell method and solving special characters issue in file path name. | ||||
|  | ||||
| %nul% reg query HKU\S-1-5-19 && ( | ||||
|   goto :Passed | ||||
|   ) || ( | ||||
|   if defined _elev goto :E_Admin | ||||
| ) | ||||
|  | ||||
| set "_batf=%~f0" | ||||
| set "_vbsf=%temp%\admin.vbs" | ||||
| set _PSarg="""%~f0""" -el | ||||
|  | ||||
| setlocal EnableDelayedExpansion | ||||
|  | ||||
| ( | ||||
| echo Set strArg=WScript.Arguments.Named | ||||
| echo Set strRdlproc = CreateObject^("WScript.Shell"^).Exec^("rundll32 kernel32,Sleep"^) | ||||
| echo With GetObject^("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" ^& strRdlproc.ProcessId ^& "'"^) | ||||
| echo With GetObject^("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" ^& .ParentProcessId ^& "'"^) | ||||
| echo If InStr ^(.CommandLine, WScript.ScriptName^) ^<^> 0 Then | ||||
| echo strLine = Mid^(.CommandLine, InStr^(.CommandLine , "/File:"^) + Len^(strArg^("File"^)^) + 8^) | ||||
| echo End If | ||||
| echo End With | ||||
| echo .Terminate | ||||
| echo End With | ||||
| echo CreateObject^("Shell.Application"^).ShellExecute "cmd.exe", "/c " ^& chr^(34^) ^& chr^(34^) ^& strArg^("File"^) ^& chr^(34^) ^& strLine ^& chr^(34^), "", "runas", 1 | ||||
| )>"!_vbsf!" | ||||
|  | ||||
| (%nul% cscript //NoLogo "!_vbsf!" /File:"!_batf!" -el) && ( | ||||
| del /f /q "!_vbsf!" | ||||
| exit /b | ||||
| ) || ( | ||||
| del /f /q "!_vbsf!" | ||||
| %nul% %_psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && ( | ||||
| exit /b | ||||
| ) || ( | ||||
| goto :E_Admin | ||||
| ) | ||||
| ) | ||||
| exit /b | ||||
|  | ||||
| :E_Admin | ||||
| %ELine% | ||||
| echo This script require administrator privileges. | ||||
| echo To do so, right click on this script and select 'Run as administrator'. | ||||
| goto Ced_Done | ||||
|  | ||||
| :Passed | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Set buffer height independently of window height | ||||
| ::  https://stackoverflow.com/a/13351373 | ||||
| ::  Written by @dbenham | ||||
|  | ||||
| mode con: cols=98 lines=31 | ||||
| %nul% %_psc% "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.height=36;$W.buffersize=$B;}" | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| set slp=SoftwareLicensingProduct | ||||
| set sls=SoftwareLicensingService | ||||
| set wApp=55c92734-d682-4d71-983e-d6ec3f16059f | ||||
| setlocal EnableDelayedExpansion | ||||
|  | ||||
| ::  Check Installation type | ||||
| set instype= | ||||
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v InstallationType 2^>nul') do if not errorlevel 1 set "instype=%%b" | ||||
|  | ||||
| if not "%instype%"=="Client" ( | ||||
| %ELine% | ||||
| echo Unsupported OS version [Server] Detected. | ||||
| echo OS Requirement - Windows 10 [17134] 1803 and later builds. | ||||
| goto Ced_Done | ||||
| ) | ||||
|  | ||||
| ::  Check Windows Edition | ||||
| set osedition= | ||||
| for /f "tokens=2 delims==" %%a in ('"wmic path %slp% where (ApplicationID='%wApp%' and PartialProductKey is not NULL) get LicenseFamily /VALUE" 2^>nul') 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 Ced_Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| echo _______________________________________________________________________________________________ | ||||
| echo: | ||||
| echo  Note 1 - This script can not change 'Core'(Home) to 'Non-Core' (Pro) Editions. | ||||
| echo           You'll have to do the above manually, Follow these steps. | ||||
| echo         - Disable internet. | ||||
| echo         - Go to Settings ^> Update ^& Security ^> Activation and  | ||||
| echo           Insert 'Pro' Edition Product Key VK7JG-NPHTM-C97JM-9MPGT-3V66T | ||||
| echo         - Follow on screen instructions, Done. [Incase of errors, restart the system.] | ||||
| echo: | ||||
| echo  Note 2 - Following option works only in W10 17134 (RS4) and later builds. | ||||
| echo _______________________________________________________________________________________________ | ||||
| echo: | ||||
| echo   You can change the Current Edition '%osedition%' to one of the following : | ||||
| echo _______________________________________________________________________________________________ | ||||
|  | ||||
| REM Thanks to @RPO for the help in codes | ||||
|  | ||||
| echo: | ||||
| for /f "tokens=4" %%a in ('dism /online /english /Get-TargetEditions ^| findstr /i /c:"Target Edition : "') do echo %%a | ||||
| echo: | ||||
| choice /C:21 /N /M "[1] Continue [2] Exit : " | ||||
| if %errorlevel%==1 exit /b | ||||
| echo: | ||||
|  | ||||
| for /f "tokens=4" %%a in ('dism /online /english /Get-TargetEditions ^| findstr /i /c:"Target Edition : "') do ( | ||||
|  | ||||
| choice /C:NY /N /M "Do you want to change to the %%a edition? [Y,N] : " | ||||
| if errorlevel 2 ( | ||||
|  | ||||
| call :%%a %nul% | ||||
| if "!key!"=="" cls &%ELine% &echo [%%a ^| %winbuild%] HWID Activation is Not Supported. &goto Ced_Done | ||||
|  | ||||
| cls | ||||
| echo ____________________________________________________________________ | ||||
|  | ||||
| REM  Thanks to @abbodi1406 for the WMI methods | ||||
|  | ||||
| echo: | ||||
| echo Changing the Edition to Windows 10 %%a | ||||
| wmic path %sls% where __CLASS='%sls%' call InstallProductKey ProductKey="!key!" %nul% && ( | ||||
| for /f "tokens=2 delims==" %%# in ('wmic path %slp% where "ApplicationID='%wApp%' and PartialProductKey<>null" Get ProductKeyChannel /value 2^>nul') do set "_channel=%%#" | ||||
| wmic path %sls% where __CLASS='%sls%' call RefreshLicenseStatus %nul% | ||||
| echo: | ||||
| call echo Installing %%_channel%% Key [!key!]  | ||||
| echo [Successful] | ||||
| echo: | ||||
| echo Reboot is required to properly change the Edition. | ||||
| ) || ( | ||||
| %ELine% | ||||
| echo Installing Retail/OEM Key [!key!] | ||||
| echo [Unsuccessful] | ||||
| ) | ||||
| echo ____________________________________________________________________ | ||||
|  | ||||
| goto Ced_Done | ||||
| )) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :Ced_Done | ||||
|  | ||||
| echo: | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :: 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 | ||||
|  | ||||
| :IoTEnterprise | ||||
| set "key=XQQYW-NFFMW-XJPBH-K8732-CKFFD" | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
							
								
								
									
										324
									
								
								MAS_1.4/Separate-Files-Version/Extras/OEMRET-Install_W10_Key.cmd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										324
									
								
								MAS_1.4/Separate-Files-Version/Extras/OEMRET-Install_W10_Key.cmd
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,324 @@ | ||||
| @setlocal DisableDelayedExpansion | ||||
| @echo off | ||||
|  | ||||
| :: For unattended mode, run the script with /u parameter. | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| :: ======================================================================================================= | ||||
| :: | ||||
| ::   This script is a part of 'Microsoft Activation Scripts' project. | ||||
| :: | ||||
| ::   Homepages- | ||||
| ::   NsaneForums: (Login Required) https://www.nsaneforums.com/topic/316668-microsoft-activation-scripts/ | ||||
| ::   GitHub: https://github.com/massgravel/Microsoft-Activation-Scripts | ||||
| ::   GitLab: https://gitlab.com/massgrave/microsoft-activation-scripts | ||||
| :: | ||||
| ::   Maintained by @WindowsAddict | ||||
| :: | ||||
| :: ======================================================================================================= | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| cls | ||||
| title Install Windows 10 Retail/OEM Key | ||||
| set Unattended= | ||||
| set _args= | ||||
| set _elev= | ||||
| set "_arg1=%~1" | ||||
| if not defined _arg1 goto :NoProgArgs | ||||
| set "_args=%~1" | ||||
| set "_arg2=%~2" | ||||
| if defined _arg2 set "_args=%~1 %~2" | ||||
| for %%A in (%_args%) do ( | ||||
| if /i "%%A"=="-el" set _elev=1 | ||||
| if /i "%%A"=="/u" set Unattended=1) | ||||
| :NoProgArgs | ||||
| for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G | ||||
| set "_psc=powershell" | ||||
| set "nul=1>nul 2>nul" | ||||
| set "ELine=echo: &echo ==== ERROR ==== &echo:" | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| if %winbuild% LSS 10240 ( | ||||
| %ELine% | ||||
| echo Unsupported OS version Detected. | ||||
| echo Project is supported only for Windows 10. | ||||
| goto Ins_Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Elevate script as admin and pass arguments and preventing loop | ||||
| ::  Thanks to @hearywarlot [ https://forums.mydigitallife.net/threads/.74332/ ] for the VBS method. | ||||
| ::  Thanks to @abbodi1406 for the powershell method and solving special characters issue in file path name. | ||||
|  | ||||
| %nul% reg query HKU\S-1-5-19 && ( | ||||
|   goto :Passed | ||||
|   ) || ( | ||||
|   if defined _elev goto :E_Admin | ||||
| ) | ||||
|  | ||||
| set "_batf=%~f0" | ||||
| set "_vbsf=%temp%\admin.vbs" | ||||
| set _PSarg="""%~f0""" -el | ||||
| if defined _args set _PSarg="""%~f0""" -el """%_args%""" | ||||
|  | ||||
| setlocal EnableDelayedExpansion | ||||
|  | ||||
| ( | ||||
| echo Set strArg=WScript.Arguments.Named | ||||
| echo Set strRdlproc = CreateObject^("WScript.Shell"^).Exec^("rundll32 kernel32,Sleep"^) | ||||
| echo With GetObject^("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" ^& strRdlproc.ProcessId ^& "'"^) | ||||
| echo With GetObject^("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" ^& .ParentProcessId ^& "'"^) | ||||
| echo If InStr ^(.CommandLine, WScript.ScriptName^) ^<^> 0 Then | ||||
| echo strLine = Mid^(.CommandLine, InStr^(.CommandLine , "/File:"^) + Len^(strArg^("File"^)^) + 8^) | ||||
| echo End If | ||||
| echo End With | ||||
| echo .Terminate | ||||
| echo End With | ||||
| echo CreateObject^("Shell.Application"^).ShellExecute "cmd.exe", "/c " ^& chr^(34^) ^& chr^(34^) ^& strArg^("File"^) ^& chr^(34^) ^& strLine ^& chr^(34^), "", "runas", 1 | ||||
| )>"!_vbsf!" | ||||
|  | ||||
| (%nul% cscript //NoLogo "!_vbsf!" /File:"!_batf!" -el "!_args!") && ( | ||||
| del /f /q "!_vbsf!" | ||||
| exit /b | ||||
| ) || ( | ||||
| del /f /q "!_vbsf!" | ||||
| %nul% %_psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && ( | ||||
| exit /b | ||||
| ) || ( | ||||
| goto :E_Admin | ||||
| ) | ||||
| ) | ||||
| exit /b | ||||
|  | ||||
| :E_Admin | ||||
| %ELine% | ||||
| echo This script require administrator privileges. | ||||
| echo To do so, right click on this script and select 'Run as administrator'. | ||||
| goto Ins_Done | ||||
|  | ||||
| :Passed | ||||
|  | ||||
| mode con: cols=98 lines=30 | ||||
| setlocal EnableDelayedExpansion | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Check Windows OS name | ||||
|  | ||||
| set winos= | ||||
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName 2^>nul') do if not errorlevel 1 set "winos=%%b" | ||||
| if not defined winos for /f "tokens=2* delims== " %%a in ('"wmic os get caption /value" 2^>nul') do if not errorlevel 1 set "winos=%%b" | ||||
|  | ||||
| ::  Check SKU value | ||||
|  | ||||
| set SKU= | ||||
| for /f "tokens=2 delims==" %%a IN ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" 2^>nul') do if not errorlevel 1 (set osSKU=%%a) | ||||
| if not defined SKU for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" /v OSProductPfn 2^>nul') do if not errorlevel 1 (set osSKU=%%a) | ||||
|  | ||||
| if "%osSKU%"=="" ( | ||||
| %ELine% | ||||
| echo SKU value was not detected properly. Aborting... | ||||
| goto Ins_Done | ||||
| ) | ||||
|  | ||||
| ::  Check Windows Edition with SKU value for better accuracy | ||||
|  | ||||
| set osedition= | ||||
| call :CheckEdition %nul% | ||||
|  | ||||
| if "%osedition%"=="" ( | ||||
| %ELine% | ||||
| echo [%winos% ^| %winbuild% ^| SKU:%osSKU%] HWID Activation is Not Supported. | ||||
| goto Ins_Done | ||||
| ) | ||||
|  | ||||
| set key= | ||||
| call :%osedition% %nul% | ||||
|  | ||||
| if "%key%"=="" ( | ||||
| %ELine% | ||||
| echo [%winos% ^| %winbuild%] HWID Activation is Not Supported. | ||||
| goto Ins_Done | ||||
| ) | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| if defined Unattended goto ContinueKeyInsert | ||||
|  | ||||
| cls | ||||
| echo ___________________________________________________________________________________________ | ||||
| echo: | ||||
| echo  Install [%winos% ^| %winbuild%] Retail/OEM Key  | ||||
| echo  [%key%] | ||||
| echo ___________________________________________________________________________________________ | ||||
| echo: | ||||
| choice /C:12 /N /M "[1] Continue [2] Exit : " | ||||
|  | ||||
| if errorlevel 2 exit /b | ||||
| if errorlevel 1 goto ContinueKeyInsert | ||||
|  | ||||
| :ContinueKeyInsert | ||||
|  | ||||
| cls | ||||
| echo ___________________________________________________________________________________________ | ||||
|  | ||||
| ::  Thanks to @abbodi1406 for the WMI methods | ||||
|  | ||||
| set slp=SoftwareLicensingProduct | ||||
| set sls=SoftwareLicensingService | ||||
| set wApp=55c92734-d682-4d71-983e-d6ec3f16059f | ||||
|  | ||||
| wmic path %sls% where __CLASS='%sls%' call InstallProductKey ProductKey="%key%" %nul% && ( | ||||
| for /f "tokens=2 delims==" %%# in ('wmic path %slp% where "ApplicationID='%wApp%' and PartialProductKey<>null" Get ProductKeyChannel /value 2^>nul') do set "_channel=%%#" | ||||
| wmic path %sls% where __CLASS='%sls%' call RefreshLicenseStatus %nul% | ||||
| echo: | ||||
| echo [%winos% ^| %winbuild%] | ||||
| call echo Installing %%_channel%% Key [%key%]  | ||||
| echo [Successful] | ||||
| ) || ( | ||||
| %ELine% | ||||
| echo Installing Retail/OEM Key [%key%] | ||||
| echo [Unsuccessful] | ||||
| ) | ||||
| echo ___________________________________________________________________________________________ | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :Ins_Done | ||||
| echo: | ||||
| if defined Unattended ( | ||||
| echo Exiting in 3 seconds... | ||||
| if %winbuild% LSS 7600 (ping -n 3 127.0.0.1 > nul) else (timeout /t 3) | ||||
| exit /b | ||||
| ) | ||||
| echo Press any key to exit... | ||||
| pause >nul | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| ::  Check Windows Edition with SKU value for better accuracy | ||||
|  | ||||
| :CheckEdition | ||||
|  | ||||
| for %%# in ( | ||||
| 4-Enterprise | ||||
| 27-EnterpriseN | ||||
| 48-Professional | ||||
| 49-ProfessionalN | ||||
| 98-CoreN | ||||
| 99-CoreCountrySpecific | ||||
| 100-CoreSingleLanguage | ||||
| 101-Core | ||||
| 121-Education | ||||
| 122-EducationN | ||||
| 125-EnterpriseS | ||||
| 126-EnterpriseSN | ||||
| 161-ProfessionalWorkstation | ||||
| 162-ProfessionalWorkstationN | ||||
| 164-ProfessionalEducation | ||||
| 165-ProfessionalEducationN | ||||
| 175-ServerRdsh | ||||
| 188-IoTEnterprise | ||||
| ) do for /f "tokens=1,2 delims=-" %%A in ("%%#") do ( | ||||
| if %osSKU%==%%A set "osedition=%%B" | ||||
| ) | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
|  | ||||
| :: 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" | ||||
| if "%winbuild%" EQU "17763" set "key=43TBQ-NH92J-XKTM7-KT3KK-P39PB" | ||||
| 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" | ||||
| if "%winbuild%" EQU "17763" set "key=M33WV-NHY3C-R7FPM-BQGPT-239PG" | ||||
| 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 | ||||
|  | ||||
| :IoTEnterprise | ||||
| set "key=XQQYW-NFFMW-XJPBH-K8732-CKFFD" | ||||
| exit /b | ||||
|  | ||||
| ::======================================================================================================================================== | ||||
		Reference in New Issue
	
	Block a user
	 GitHub
						GitHub