Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
337 views12 pages

Activation Windows

Download as txt, pdf, or txt
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 12

<!

-- ::
@echo off

:: For unattended mode, run the script with /u parameter.

::=================================================================================
=======================================================

: Credits:

:
===================================================================================
========================================
: *Anonymous and @mspaintmsi - Original (co)Authors of HWID and KMS38 Activation
without KMS or predecessor install/upgrade
: - Created various methods for HWID and KMS38
Activation
: https://www.nsaneforums.com/topic/316668--/?
do=findComment&comment=1497887

: @vyvojar - Original slshim (slc.dll)


: https://github.com/vyvojar/slshim/releases

: Suggestions and improvements.

: @sponpa - New ideas for the HWID/KM38 Generation


:
https://www.nsaneforums.com/topic/316668--/page/21/?tab=comments#comment-1431257

: @leitek8 - Improvements for the slc.dll


:
https://www.nsaneforums.com/topic/316668--/page/22/?tab=comments#comment-1438005
:
===================================================================================
========================================

:
===================================================================================
========================================
: This script is a part of 'Microsoft Activation Scripts'
: Maintained by @WindowsAddict
: Homepage - https://www.nsaneforums.com/topic/316668--/

: P.S. I (@WindowsAddict) didn't help in the development of HWID/KMS38 Activation


in any way, I only manage batch script
: tool which is based on the above mentioned Original Authors activation methods.
:
===================================================================================
========================================

::=================================================================================
=======================================================
::=================================================================================
=======================================================

cls
title KMS38 Activation
if /i "%*" EQU "/u" (set Unattended=1) else (set Unattended=0)
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" >
NUL && set arch=x86|| set arch=x64
set "nul=>nul 2>&1"
set "ELine=echo. &call :Color 4F "==== ERROR ====" &echo:&echo."
setlocal EnableDelayedExpansion
call :Color_Pre

::=================================================================================
=======================================================

: ===========================================================
: 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 14393 (


%ELine%
echo Unsupported OS version Detected.
echo Project is supported only for Windows 10/Server 1607 [14393] and later builds.
goto Done
)

::=================================================================================
=======================================================

: ==========================================================
: self-elevate passing args and preventing loop
: using wsf - needs the 1st and the last 2 lines in place)
: Written by @AveYo aka @BAU
: ==========================================================

reg query HKU\S-1-5-19 >nul 2>nul && goto GotPrivileges


if "%?%" equ "y" goto ElevationError

set "args="%~f0" %*"


call cscript /nologo "%~f0?.wsf" //job:adm && exit /b

:ElevationError
%ELine%
echo Right click on this file and select 'Run as administrator'
goto Done

:GotPrivileges

::=================================================================================
=======================================================

mode con: cols=110 lines=32


cd /d "%~dp0"
pushd "%~dp0"

if not exist "%~dp0Files\" (


%ELine%
echo 'Files' Folder does not exist in current directory.
echo It's supposed to have files required for the Activation.
goto Done
)

call :check gatherosstate.exe slc.dll


if defined _miss goto Done

::=================================================================================
=======================================================

copy /y nul "%~dp0Files\#.rw" %nul% && (


if exist "%~dp0Files\#.rw" del /f /q "%~dp0Files\#.rw"
) || (
%ELine%
echo 'Files' Folder in current directory is write protected.
echo Copy the Activator's package to a writable directory.
goto Done
)

::=================================================================================
=======================================================

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
)

::=================================================================================
=======================================================

call :CheckPermAct
if [!Perm!]==[1] (

echo ----------------------------------------------
echo Checking: Windows is Permanently Activated.
echo Activation is not required.
echo ----------------------------------------------
echo.
if %Unattended% EQU 1 goto Done

echo ----------------------------------------
echo Press [A] or [B] button in Keyboard :
echo ----------------------------------------
echo.
choice /C:AB /N /M "[A] I still want to Activate [B] Exit : "

if errorlevel 2 exit /b
if errorlevel 1 goto continue
)

::=================================================================================
=======================================================

:Continue

cls
set key=
call :%osedition% %nul%

if "%Key%"=="" (
%ELine%
echo [%osedition% ^| %winbuild%] KMS38 Activation is Not Supported.
goto Done
)

for /d %%# in (ServerStandardCor ServerDatacenterCor ServerSolutionCor


ServerStandardACor ServerDatacenterACor) do if "%osedition%"=="%%#" set A_Cor=1

if defined A_Cor (
call :check clipup.exe
if defined _miss goto Done
)

::=================================================================================
=======================================================

cd /d "%~dp0"
if exist "%~dp0Files\*.xml" del /f /q "%~dp0Files\*.xml"
if exist "%~dp0Files\gatherosstatemodified.exe" del /f /q
"%~dp0Files\gatherosstatemodified.exe"
cls

echo Checking OS Info [%osedition% ^| %winbuild% ^| %arch%]


echo.
set _1=ClipSVC
set _3=sppsvc

for %%# in (%_1% %_3%) do call :ServiceCheck %%#

set "CLecho=Checking %_1% [Service Status -%Cl_state%]


[Startup Type -%Cl_start_type%]"
set "specho=Checking %_3% [Service Status -%sp_state%]
[Startup Type -%sp_start_type%]"

if not "%Cl_start_type%"=="Demand" (call :Color 4F "%CLecho%" &echo: & set


Clst_e=1) else (echo %CLecho%)
if not "%sp_start_type%"=="Delayed-Auto" (call :Color 4F "%specho%" &echo: & set
spst_e=1) else (echo %specho%)

echo.
if defined Clst_e (sc config %_1% start= Demand %nul% && set Clst_s=%_1%-
Demand || set Clst_u=%_1%-Demand )
if defined spst_e (sc config %_3% start= Delayed-Auto %nul% && set spst_s=%_3%-
Delayed-Auto || set spst_u=%_3%-Delayed-Auto )

for %%# in (Clst_s,spst_s) do if defined %%# set st_s=1


if defined st_s (echo Changing services Startup Type to [ %Clst_s%%spst_s%]
[Successful])

for %%# in (Clst_u,spst_u) do if defined %%# set st_u=1


if defined st_u (call :Color 4F "Error in changing Startup Type to [ %Clst_u%
%spst_u%]" &echo:)

if not "%Cl_state%"=="Running" (Powershell -NoProfile start-service %_1% %nul% &&


set Cl_s=%_1% || set Cl_u=%_1% )
if not "%sp_state%"=="Running" (Powershell -NoProfile start-service %_3% %nul% &&
set sp_s=%_3% || set sp_u=%_3% )

for %%# in (Cl_s,sp_s) do if defined %%# set s_s=1


if defined s_s (echo Starting services [ %Cl_s%%sp_s%]
[Successful])

for %%# in (Cl_u,sp_u) do if defined %%# set s_u=1


if defined s_u (call :Color 4F "Error in starting services [ %Cl_u%
%sp_u%]" &echo:)

echo.
cscript /nologo %windir%\system32\slmgr.vbs -ipk %key%

: ======================================
: Set specific KMS host to Local Host
: Written by @abbodi1406 (MDL)
: ======================================

set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"


reg delete "HKLM\%SPPk%\55c92734-d682-4d71-983e-d6ec3f16059f" /f %nul%
reg delete "HKU\S-1-5-20\%SPPk%\55c92734-d682-4d71-983e-d6ec3f16059f" /f %nul%

set "setkms_=Setting specific KMS host to 127.0.0.2 "


set spp=SoftwareLicensingProduct
set "app="
for /f "tokens=2 delims==" %%G in ('"wmic path %spp% where (Description like '%
%KMSCLIENT%%' and Name like 'Windows%%' and PartialProductKey is not NULL) get
ID /VALUE"') do (set app=%%G)
if not "%app%"=="" (
wmic path %spp% where ID='%app%' call ClearKeyManagementServiceMachine %nul% ||
(set setkms_error=1)
wmic path %spp% where ID='%app%' call ClearKeyManagementServicePort %nul% || (set
setkms_error=1)
wmic path %spp% where ID='%app%' call SetKeyManagementServiceMachine
MachineName="127.0.0.2" %nul% || (set setkms_error=1)
wmic path %spp% where ID='%app%' call SetKeyManagementServicePort 1688 %nul% ||
(set setkms_error=1)
) else (set setkms_error=1)

if not defined setkms_error (


echo %setkms_% [Successful]
) else (
call :Color 4F "%setkms_% [Unsuccessful]" &echo:
)

call "%~dp0Files\gatherosstate.exe"

set "GenTicket=Generating GenuineTicket.xml "


if not exist "%~dp0Files\GenuineTicket.xml" (
call :Color 4F "%GenTicket% [Unsuccessful]" &echo:
) else (
echo %GenTicket% [Successful]
)

echo Installing GenuineTicket.xml


if defined A_Cor (
"%~dp0Files\clipup.exe" -v -o -altto Files\
) else (
clipup -v -o -altto Files\
)

echo.
set "Act=Activation "
cscript /nologo %windir%\system32\slmgr.vbs -ato %nul%

call :CheckEXPtime
if %gpr% GTR 259200 (
call :Actinfo
goto Done
)

: ====================================================================
: Clear 180 Days KMS Activation lock without full Rearm and Restart
: Concept taken from the @Ratiborus Tools
: http://forum.ru-board.com/topic.cgi?forum=2&topic=5734#1
: ====================================================================

set "Rearm=Applying SKU-APP ID Rearm "


cscript /nologo %windir%\system32\slmgr.vbs /rearm-app 55c92734-d682-4d71-983e-
d6ec3f16059f %nul% || (set RearmF=1)
cscript /nologo %windir%\system32\slmgr.vbs /rearm-sku %app% %nul% || (set
RearmF=1)

if defined RearmF (
call :Color 4F "%Rearm% [Unsuccessful]" &echo:
) else (
echo %Rearm% [Successful]
)

echo.
call :CheckEXPtime
if %gpr% GTR 259200 (
call :Actinfo
goto Done
)

call :ActivationRetry
call :CheckEXPtime
if %gpr% GTR 259200 (
call :Actinfo
goto Done
)

call :Color 4F "%Act% [Unsuccessful] [Error Code %ErrCode%]" &echo:


call :Color 5F "Try the Troubleshoot Guide listed in the ReadMe File" &echo: &echo.

goto Done

::=================================================================================
=======================================================

: ================================
: Echo all the missing files.
: Written by @abbodi1406 (MDL)
: ================================

:check
for %%# in (%1 %2) do (if not exist "%~dp0Files\%%#" (if defined _miss (set
"_miss=!_miss! %%#") else (set "_miss=%%#")))
if defined _miss (
%ELine%
echo Following required file^(s^) is missing in 'Files' folder. Aborting...
echo.
echo !_miss!
)
exit /b

::=================================================================================
=======================================================

:ServiceCheck

: ======================================
: Detect Service status and start type
: Written by @RPO (MDL)
: ======================================

for /f "tokens=1,3 delims=: " %%a in ('sc query %1') do (if /i %%a==state set
"state=%%b")
for /f "tokens=1-4 delims=: " %%a in ('sc qc %1') do (if /i %%a==start_type set
"start_type=%%c %%d")

if /i "%state%"=="STOPPED" set state=Stopped


if /i "%state%"=="RUNNING" set state=Running

if /i "%start_type%"=="auto_start (delayed)" set start_type=Delayed-Auto


if /i "%start_type%"=="auto_start " set start_type=Auto
if /i "%start_type%"=="demand_start " set start_type=Demand
if /i "%start_type%"=="disabled " set start_type=Disabled

for %%i in (%*) do (


if /i "%%i"=="%_3%" set "sp_start_type=%start_type%" & set "sp_state=%state%"
if /i "%%i"=="%_1%" set "Cl_start_type=%start_type%" & set "Cl_state=%state%"
)
exit /b

::=================================================================================
=======================================================

:CheckPermAct

: ===========================================
: Check Windows Permanent Activation status
: Written by @abbodi1406 (MDL)
: ===========================================

wmic path SoftwareLicensingProduct where (LicenseStatus='1' and


GracePeriodRemaining='0' and PartialProductKey is not NULL) get Name 2>nul |
findstr /i "Windows" 1>nul && set Perm=1||set Perm=0
exit /b

::=================================================================================
=======================================================

:ActivationRetry

Powershell -NoProfile Restart-Service sppsvc %nul%

: ======================================
: Detect Error Code in the Activation
: Written by @abbodi1406 (MDL)
: ======================================

WMIC PATH SoftwareLicensingProduct WHERE (Name like 'Windows%%' and


PartialProductKey is not NULL) CALL Activate >nul 2>&1
set errorcode=%errorlevel%
cmd /c exit /b %errorcode%
if %errorcode% NEQ 0 set "ErrCode=0x%=ExitCode%"
exit /b

::=================================================================================
=======================================================

:Actinfo
call :Color 2F "%Act% [Successful]" &echo:
cscript /nologo %windir%\system32\slmgr.vbs -xpr
exit /b

::=================================================================================
=======================================================

:CheckEXPtime
: ======================================
: Check Activation remaining time
: Written by @abbodi1406 (MDL)
: ======================================

for /f "tokens=2 delims==" %%# in ('"wmic path SoftwareLicensingProduct where


(Description like '%%KMSCLIENT%%' and Name like 'Windows%%' and PartialProductKey
is not NULL) get GracePeriodRemaining /VALUE" ') do set "gpr=%%#"
exit /b

::=================================================================================
=======================================================

: ======================================================
: Multicolor outputs without any external programs
: https://stackoverflow.com/a/5344911
: Written by @jeb (stackoverflow)
: ======================================================

:Color_Pre
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do
rem"') do (set "DEL=%%a") &exit /b

:color
pushd "%temp%"
<nul set /p ".=%DEL%" > "%~2" &findstr /v /a:%1 /R "^$" "%~2" nul &del "%~2" > nul
2>&1 &popd &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

::=================================================================================
=======================================================

:: Generic Volume License Key (GVLK) List

:Core
set "key=TX9XD-98N7V-6WMQ6-BX7FG-H8Q99"
exit /b

:CoreCountrySpecific
set "key=PVMJN-6DFY6-9CCP6-7BKTT-D3WVR"
exit /b

:CoreN
set "key=3KHY7-WNT83-DGQKR-F7HPR-844BM"
exit /b

:CoreSingleLanguage
set "key=7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH"
exit /b

:Education
set "key=NW6C2-QMPVW-D7KKK-3GKT6-VCFB2"
exit /b

:EducationN
set "key=2WH4N-8QGBV-H22JP-CT43Q-MDWWJ"
exit /b

:Enterprise
set "key=NPPR9-FWDCX-D2C8J-H872K-2YT43"
exit /b

:EnterpriseG
set "key=YYVX9-NTFWV-6MDM3-9PT4T-4M68B"
exit /b

:EnterpriseGN
set "key=44RPN-FTY23-9VTTB-MP9BX-T84FV"
exit /b

:EnterpriseN
set "key=DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4"
exit /b

:EnterpriseS
if "%winbuild%" EQU "14393" set "key=DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ"
if "%winbuild%" EQU "17763" set "key=M7XTQ-FN8P6-TTKYV-9D4CC-J462D"
exit /b

:EnterpriseSN
if "%winbuild%" EQU "14393" set "key=QFFDN-GRT3P-VKWWX-X7T3R-8B639"
if "%winbuild%" EQU "17763" set "key=92NFX-8DJQP-P6BBQ-THF9C-7CG2H"
exit /b

:Professional
set "key=W269N-WFGWX-YVC9B-4J6C9-T83GX"
exit /b

:ProfessionalEducation
set "key=6TP4R-GNPTD-KYYHQ-7B7DP-J447Y"
exit /b

:ProfessionalEducationN
set "key=YVWGF-BXNMC-HTQYQ-CPQ99-66QFC"
exit /b

:ProfessionalN
set "key=MH37W-N47XK-V7XM9-C7227-GCQG9"
exit /b

:ProfessionalWorkstation
set "key=NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J"
exit /b
:ProfessionalWorkstationN
set "key=9FNHH-K3HBT-3W4TD-6383H-6XYWF"
exit /b

:ServerCloudStorage
if "%winbuild%" EQU "14393" set "key=QN4C6-GBJD2-FB422-GHWJK-GJG2R"
exit /b

:ServerDatacenter
if "%winbuild%" EQU "14393" set "key=CB7KF-BWN84-R7R2Y-793K2-8XDDG"
if "%winbuild%" EQU "17763" set "key=WMDGN-G9PQG-XVVXX-R3X43-63DFG"
exit /b

:ServerDatacenterACor
if "%winbuild%" EQU "16299" set "key=6Y6KB-N82V8-D8CQV-23MJW-BWTG6"
if "%winbuild%" EQU "17134" set "key=2HXDN-KRXHB-GPYC7-YCKFJ-7FVDG"
if "%winbuild%" EQU "17763" set "key=6NMRW-2C8FM-D24W7-TQWMY-CWH2D"
if "%winbuild%" GEQ "18362" set "key=TX3M3-HN6CW-2D8RM-QKCVK-WT3F3"
exit /b

:ServerDatacenterCor
if "%winbuild%" EQU "14393" set "key=CB7KF-BWN84-R7R2Y-793K2-8XDDG"
if "%winbuild%" EQU "17763" set "key=WMDGN-G9PQG-XVVXX-R3X43-63DFG"
exit /b

:ServerRdsh
if "%winbuild%" LSS "17763" set "key=7NBT4-WGBQX-MP4H7-QXFF8-YP3KX"
if "%winbuild%" GEQ "17763" set "key=CPWHC-NT2C7-VYW78-DHDB2-PG3GK"
exit /b

:ServerSolution
if "%winbuild%" EQU "14393" set "key=JCKRF-N37P4-C2D82-9YXRT-4M63B"
if "%winbuild%" EQU "17763" set "key=WVDHN-86M7X-466P6-VHXV7-YY726"
exit /b

:ServerSolutionCor
if "%winbuild%" EQU "14393" set "key=JCKRF-N37P4-C2D82-9YXRT-4M63B"
if "%winbuild%" EQU "17763" set "key=WVDHN-86M7X-466P6-VHXV7-YY726"
exit /b

:ServerStandard
if "%winbuild%" EQU "14393" set "key=WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY"
if "%winbuild%" EQU "17763" set "key=N69G4-B89J2-4G8F4-WWYCC-J464C"
exit /b

:ServerStandardACor
if "%winbuild%" EQU "16299" set "key=DPCNP-XQFKJ-BJF7R-FRC8D-GF6G4"
if "%winbuild%" EQU "17134" set "key=PTXN8-JFHJM-4WC78-MPCBR-9W4KR"
if "%winbuild%" EQU "17763" set "key=N2KJX-J94YW-TQVFB-DG9YT-724CC"
if "%winbuild%" GEQ "18362" set "key=PHN2T-WHKP4-X8RTQ-TD9TT-D3YPC"
exit /b

:ServerStandardCor
if "%winbuild%" EQU "14393" set "key=WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY"
if "%winbuild%" EQU "17763" set "key=N69G4-B89J2-4G8F4-WWYCC-J464C"
exit /b

::=================================================================================
=======================================================

exit/b --><package><job id="adm"><script


language="VBScript">args=CreateObject("WScript.Shell").ExpandEnvironmentStrings("%a
rgs%")
RunAs=CreateObject("Shell.Application").ShellExecute("cmd.exe","/c set ?=y&call
"&args,,"runas")</script></job></package>

You might also like