0% found this document useful (0 votes)
26 views

Digital_License_Activation

Microsoft Activation Scripts

Uploaded by

Dustin DeShaney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Digital_License_Activation

Microsoft Activation Scripts

Uploaded by

Dustin DeShaney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

@echo off

:: Change 0 to 1 to run the script Unattended


set Unattended=0

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

:: ----------------------------------------------------
:: This script was initially written by @s1ave77
:: Later improved by @RPO and Me (@WindowsAddict)
:: ----------------------------------------------------

::
-----------------------------------------------------------------------------------
----------------------
:: This script is a part of "Microsoft Activation Scripts" - Fork, Open Source &
clean from AV's detection
:: Homepage - https://www.nsaneforums.com/topic/316668--/ ShortURL - 0x0.st/s9j

::
-----------------------------------------------------------------------------------
----------------------

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

fsutil dirty query %systemdrive% >nul 2>&1 || (

echo ==== ERROR ====


echo Right click on this script and select 'Run as administrator'
goto Done
)

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

for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G

if %winbuild% LSS 10240 (


echo ==== ERROR ====
echo Unsupported OS version Detected.
echo Project is supported only for Windows 10.
goto Done
)

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

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

if not exist "%~dp0Files\" (


echo ==== ERROR ====
echo Following 'Files' Folder does not exist.
echo It's supposed to have files required for the Activation.
echo.
echo %~dp0Files\
goto Done
)

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

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


if exist "%~dp0Files\#.rw" del /f /q "%~dp0Files\#.rw"
) || (
echo ==== ERROR ====
echo Following directory is write protected.
echo.
echo %~dp0Files\
echo.
echo Copy the script and above Folder to a writable directory.
goto Done
)

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

title [Fork] Digital License Activation - Windows 10


color 1F
setlocal enabledelayedexpansion
setlocal EnableExtensions

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

wmic path SoftwareLicensingProduct where (LicenseStatus='1' and


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

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

:: ------------------------------
:: Detect edition, key and sku
:: Written by @RPO (MDL)
:: ------------------------------

cls
call :Retail_OEM_Key
call :DetectEdition

for /f "tokens=1-4 usebackq" %%a in ("%TEMP%\editions") do (if ^[%


%a^]==^[%osedition%^] (
set edition=%%a
set sku=%%b
set Key=%%c
del /f "%temp%\editions"
goto:ParseAndPatch))

echo.
del /f "%temp%\editions"
echo %osedition% Digital License Activation is Not Supported.
goto Done

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

:ParseAndPatch

:: ----------------------------------------------------
:: Multicolor outputs without any external programs
:: https://stackoverflow.com/a/5344911
:: Written by @jeb (stackoverflow)
:: ----------------------------------------------------
cls
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do
rem"') do (set "DEL=%%a")
set "color=call :Color 0C "
goto :SkipColor

:color

pushd "%temp%"
<nul set /p ".=%DEL%" > "%~2" &findstr /v /a:%1 /R "^$" "%~2" nul &del "%~2" > nul
2>&1
popd
goto :eof

:SkipColor

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

echo.
cd /d "%~dp0"

if %winbuild% EQU 10240 (


if "%osedition%"=="EnterpriseS2015" set
"gatherosstate_type=gatherosstate_ltsb2015.exe"
if "%osedition%"=="EnterpriseSN2015" set
"gatherosstate_type=gatherosstate_ltsb2015.exe"
) else (
set "gatherosstate_type=gatherosstate.exe"
)
set "gatherosstate=%~dp0Files\%gatherosstate_type%"

if not exist "%gatherosstate%" (set no_file=1 & set no_gather=1)


if not exist "%~dp0Files\slc.dll" (set no_file=1 & set no_slc=1)

if defined no_file (
%color% "Following required file[s] are not present - Aborting" &echo:
echo.
if defined no_gather echo %gatherosstate%
if defined no_slc echo %~dp0Files\slc.dll
goto Done
)

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

reg add "HKLM\SYSTEM\Tokens" /v "Channel" /t REG_SZ /d "Retail" /f >nul 2>&1 ||


(set reg_error=1)
reg add "HKLM\SYSTEM\Tokens\Kernel" /v "Kernel-ProductInfo" /t REG_DWORD /d %sku
% /f >nul 2>&1 || (set reg_error=1)
reg add "HKLM\SYSTEM\Tokens\Kernel" /v "Security-SPP-GenuineLocalStatus" /t
REG_DWORD /d 1 /f >nul 2>&1 || (set reg_error=1)

set "Add_reg=Adding Registry Entries.. "


if defined reg_error (
%color% "%Add_reg% [Unsuccessful]" &echo:
) else (
echo %Add_reg% [Successful]
)

echo Running %gatherosstate_type%..


start /wait "" "%gatherosstate%"
timeout /t 3 >nul 2>&1

echo Installing Genuine Ticket.xml..


clipup -v -o -altto Files\

set "Rem_reg=Removing Registry Entries.. "


reg delete "HKLM\SYSTEM\Tokens" /f >nul 2>&1 && (
echo %Rem_reg% [Successful]
) || (
%color% "%Rem_reg% [Unsuccessful]" &echo:
)

set "Chkint=Checking Internet Connection.. "


ping www.microsoft.com > nul && (
echo %Chkint% [Connected]
) || (
%color% "%Chkint% [Not connected]" &echo:
)

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

if "%start_type%"=="AUTO_START (DELAYED)" set start_type=DELAYED-AUTO


if "%start_type%"=="AUTO_START " set start_type=AUTO
if "%start_type%"=="DEMAND_START " set start_type=DEMAND
if "%start_type%"=="DISABLED " set start_type=DISABLED

echo Checking Windows Update Service.. [Startup Type :%start_type%] [Service


Status :%state%]

set "changing_start_type=Changing WU Startup Type to Auto.. "


if not "%start_type%"=="AUTO" (
sc config wuauserv start= auto >nul 2>&1 && (
echo %changing_start_type% [Successful] &set start_type_S=1
) || (
%color% "%changing_start_type% [Unsuccessful]" &echo: &set error_=1
)
)

set "changing_status=Changing WU Service Status to Running.."


if not "%state%"=="RUNNING" (
net start wuauserv >nul 2>&1 && (
echo %changing_status% [Successful] &set state_S=1
) || (
%color% "%changing_status% [Unsuccessful]" &echo: &set error_=1
)
)

if defined error_ (%color% "Error reason - Most likely Windows Update service is
protected with some methods." &echo:)

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

set "changing_start_type_back=Changing WU Startup Type back to.. [%start_type


%]"
if defined start_type_S (
sc config wuauserv start= %start_type% >nul 2>&1 && (
echo %changing_start_type_back% [Successful]
) || (
%color% "%changing_start_type_back% [Unsuccessful]" &echo:
)
)

set "changing_status_back=Changing WU Service Status back to.. [%state%]"


if defined state_S (
net stop wuauserv >nul 2>&1 && (
echo %changing_status_back% [Successful]
) || (
%color% "%changing_status_back% [Unsuccessful]" &echo:
)
)

goto Done

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

:DetectEdition

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")

if %winbuild% EQU 10240 (


if "%osedition%"=="EnterpriseS" set "osedition=EnterpriseS2015"
if "%osedition%"=="EnterpriseSN" set "osedition=EnterpriseSN2015"
)
if %winbuild% EQU 14393 (
if "%osedition%"=="EnterpriseS" set "osedition=EnterpriseS2016"
if "%osedition%"=="EnterpriseSN" set "osedition=EnterpriseSN2016"
)
if %winbuild% GEQ 17763 (
if "%osedition%"=="EnterpriseS" set "osedition=EnterpriseS2019"
if "%osedition%"=="EnterpriseSN" set "osedition=EnterpriseSN2019"
)
exit /b

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

:Retail_OEM_Key
rem Edition SKU Retail/OEM_Key
(
echo Core 101 YTMG3-N6DKC-DKB77-7M9GH-8HVX7
echo CoreN 98 4CPRK-NM3K3-X6XXQ-RXX86-WXCHW
echo CoreCountrySpecific 99 N2434-X9D7W-8PF6X-8DV9T-8TYMD
echo CoreSingleLanguage 100 BT79Q-G7N6G-PGBYW-4YWX6-6F4BT
echo Education 121 YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY
echo EducationN 122 84NGF-MHBT6-FXBX8-QWJK7-DRR8H
echo Enterprise 4 XGVPP-NMH47-7TTHJ-W3FW7-8HV2C
echo EnterpriseN 27 3V6Q6-NQXCX-V8YXR-9QCYV-QPFCT
echo EnterpriseS2015 125 FWN7H-PF93Q-4GGP8-M8RF3-MDWWW
echo EnterpriseSN2015 126 8V8WN-3GXBH-2TCMG-XHRX3-9766K
echo EnterpriseS2016 125 NK96Y-D9CD8-W44CQ-R8YTK-DYJWX
echo EnterpriseSN2016 126 2DBW3-N2PJG-MVHW3-G7TDK-9HKR4
echo Professional 48 VK7JG-NPHTM-C97JM-9MPGT-3V66T
echo ProfessionalN 49 2B87N-8KFHP-DKV6R-Y2C8J-PKCKT
echo ProfessionalEducation 164 8PTT6-RNW4C-6V7J2-C2D3X-MHBPB
echo ProfessionalEducationN 165 GJTYN-HDMQY-FRR76-HVGC7-QPF8P
echo ProfessionalWorkstation 161 DXG7C-N36C4-C4HTG-X4T3X-2YV77
echo ProfessionalWorkstationN 162 WYPNQ-8C467-V2W6J-TX4WX-WT2RQ
echo ServerRdsh 175 NJCF7-PW8QT-3324D-688JX-2YV66

) > "%TEMP%\editions" &exit /b

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

:Done

echo.
if %Unattended% EQU 1 echo Exiting in 10 seconds... & ping -n 11 127.0.0.1 > nul &
exit /b
echo Press any key to exit...
pause >nul
exit /b

You might also like