1
0
mirror of https://github.com/massgravel/Microsoft-Activation-Scripts.git synced 2025-02-22 12:59:57 +00:00

16 Commits
1.6 ... 1.8

Author SHA1 Message Date
DESKTOP-AJSJJMA\Admin
3c4f8796fa 1.8 2023-03-16 11:11:04 -07:00
DESKTOP-AJSJJMA\Admin
4b8a769f54 Revert "Change hash to evade some AV's"
This reverts commit 044d5f8ae7532728ed754f7441506eb0a888d3bc.
2023-01-24 11:25:44 -08:00
DESKTOP-AJSJJMA\Admin
044d5f8ae7 Change hash to evade some AV's 2023-01-24 02:32:57 -08:00
DESKTOP-AJSJJMA\Admin
0b6ec943b1 Evade Kaspersky's flagging 2022-12-17 00:20:24 -08:00
WindowsAddict
ed91ab5ac2 Update 1.7 2022-11-08 02:06:53 +05:30
DESKTOP-AJSJJMA\Admin
bc8ae03488 1.7 2022-11-07 12:33:01 -08:00
WindowsAddict
d17d7496e0 Shortened Powershell download code 2022-08-27 09:11:11 +05:30
WindowsAddict
22938f30e1 Update README.md 2022-08-24 12:16:29 +05:30
WindowsAddict
987b518ba1 Update README.md 2022-08-23 13:22:57 +05:30
WindowsAddict
eecd977184 Update README.md 2022-08-23 13:22:13 +05:30
WindowsAddict
7323b3ab18 Update README.md 2022-08-23 13:11:16 +05:30
WindowsAddict
f551f61998 Update README.md 2022-08-17 00:50:06 +05:30
WindowsAddict
43ce3cc4be Update README.md 2022-08-17 00:49:41 +05:30
WindowsAddict
6791e7a73f Update README.md 2022-08-13 03:17:16 +05:30
WindowsAddict
f0fefb7baa Update README.md 2022-08-10 21:29:47 +05:30
WindowsAddict
73b1085da6 Update README.md 2022-07-27 08:13:24 +05:30
19 changed files with 5721 additions and 7579 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,10 @@
:: To stage current edition while changing edition with CBS Upgrade Method, change 0 to 1 in below line
set _stg=0
::======================================================================================================================================== ::========================================================================================================================================
@ -53,10 +57,9 @@ pushd "%~dp0"
>nul findstr /rxc:".*" "%~nx0" >nul findstr /rxc:".*" "%~nx0"
if not %errorlevel%==0 ( if not %errorlevel%==0 (
echo: echo:
echo Error: This is not a correct file. It has LF line ending issue. echo Error: Script either has LF line ending issue, or it failed to read itself.
echo: echo:
echo Press any key to exit... ping 127.0.0.1 -n 6 > nul
pause >nul
popd popd
exit /b exit /b
) )
@ -102,13 +105,14 @@ set "_Yellow="Black" "Yellow""
set "nceline=echo: &echo ==== ERROR ==== &echo:" set "nceline=echo: &echo ==== ERROR ==== &echo:"
set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:" set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:"
set "line=echo ___________________________________________________________________________________________" set "line=echo ___________________________________________________________________________________________"
if %~z0 GEQ 200000 (set "_exitmsg=Go back") else (set "_exitmsg=Exit")
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% LSS 10240 ( if %winbuild% LSS 7600 (
%eline% %nceline%
echo Unsupported OS version detected. echo Unsupported OS version detected.
echo Project is supported for Windows 10/11/Server Build 10240 and later. echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalent.
goto ced_done goto ced_done
) )
@ -151,7 +155,7 @@ goto ced_done
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul% reg query HKU\S-1-5-19 || ( >nul fltmc || (
if not defined _elev %nul% %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b if not defined _elev %nul% %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b
%eline% %eline%
echo This script require administrator privileges. echo This script require administrator privileges.
@ -164,36 +168,52 @@ goto ced_done
cls cls
mode 98, 30 mode 98, 30
call :dk_initial echo:
echo Initializing...
echo:
call :dk_product
call :dk_ckeckwmic
if not defined applist ( :: Show info for potential script stuck scenario
cls
%eline% sc start sppsvc %nul%
echo Not Respoding: !e_wmispp! if %errorlevel% NEQ 1056 if %errorlevel% NEQ 0 (
goto ced_done echo:
echo Error code: %errorlevel%
call :dk_color %Red% "Failed to start [sppsvc] service, rest of the process may take a long time..."
echo:
) )
::======================================================================================================================================== ::========================================================================================================================================
:: Check Activation IDs
call :dk_actids
if not defined applist (
%eline%
echo Activation IDs not found. Aborting...
echo:
echo Check this page for help. https://massgrave.dev/troubleshoot
goto ced_done
)
:: Check Windows Edition :: Check Windows Edition
set osedition= set osedition=
for /f "tokens=3 delims=: " %%a in ('DISM /English /Online /Get-CurrentEdition 2^>nul ^| find /i "Current Edition :"') do set "osedition=%%a" 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%"=="" ( if "%osedition%"=="" (
%eline% %eline%
DISM /English /Online /Get-CurrentEdition %nul% DISM /English /Online /Get-CurrentEdition %nul%
cmd /c exit /b !errorlevel! cmd /c exit /b !errorlevel!
echo DISM command failed [Error Code - 0x!=ExitCode!] echo DISM command failed [Error Code - 0x!=ExitCode!]
echo OS Edition was not detected properly. Aborting... echo OS Edition was not detected properly. Aborting...
echo:
echo Check this page for help. https://massgrave.dev/troubleshoot
goto ced_done goto ced_done
) )
:: Check product name
call :dk_product
:: Check SKU value :: Check SKU value
set osSKU= set osSKU=
@ -213,6 +233,9 @@ echo SKU value was not detected properly. Aborting...
goto ced_done goto ced_done
) )
set branch=
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildBranch 2^>nul') do set "branch=%%b"
:: Check PowerShell :: Check PowerShell
%psc% $ExecutionContext.SessionState.LanguageMode 2>nul | find /i "Full" 1>nul || ( %psc% $ExecutionContext.SessionState.LanguageMode 2>nul | find /i "Full" 1>nul || (
@ -221,25 +244,17 @@ echo PowerShell is not responding properly. Aborting...
goto ced_done goto ced_done
) )
:: Check slmgr /dlv
cscript //nologo %windir%\system32\slmgr.vbs /dlv %nul%
set error_code=%errorlevel%
cmd /c exit /b %error_code%
if %error_code% NEQ 0 set "error_code=[0x%=ExitCode%]"
if %error_code% NEQ 0 (
%eline%
echo slmgr /dlv is not responding %error_code%
goto ced_done
)
::======================================================================================================================================== ::========================================================================================================================================
:: Get Target editions list :: Get Target editions list
set _target= set _target=
set _dtarget=
set _ptarget=
set _ntarget= set _ntarget=
for /f "tokens=4" %%a in ('dism /online /english /Get-TargetEditions ^| findstr /i /c:"Target Edition : "') do (if defined _target (set "_target=!_target! %%a") else (set "_target=%%a"))
if %winbuild% GEQ 10240 for /f "tokens=4" %%a in ('dism /online /english /Get-TargetEditions ^| findstr /i /c:"Target Edition : "') do (if defined _dtarget (set "_dtarget=!_dtarget! %%a") else (set "_dtarget=%%a"))
for /f "tokens=4" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -GetTargetEditions;" ^| findstr /i /c:"Target Edition : "') do (if defined _ptarget (set "_ptarget=!_ptarget! %%a") else (set "_ptarget=%%a"))
::======================================================================================================================================== ::========================================================================================================================================
@ -253,9 +268,13 @@ echo Aborting...
goto ced_done goto ced_done
) )
for %%# in ( %_dtarget% %_ptarget% ) do (
echo "!_target!" | find /i " %%# " 1>nul || set "_target=!_target! %%# "
)
if defined _target ( if defined _target (
for %%# in (%_target%) do ( for %%# in (%_target%) do (
echo %%# | findstr /i "CountrySpecific CloudEdition" %nul% || (if defined _ntarget (set "_ntarget=!_ntarget! %%#") else (set "_ntarget=%%#")) echo %%# | findstr /i "CountrySpecific CloudEdition" %nul% || (set "_ntarget=!_ntarget! %%#")
) )
) )
@ -275,26 +294,40 @@ goto ced_done
cls cls
mode 98, 30 mode 98, 30
set inpt= set inpt=
set note=
set counter=0 set counter=0
set verified=0 set verified=0
set targetedition= set targetedition=
%line% %line%
echo: echo:
call :dk_color %Gray% "You can change the Current Edition [%osedition%] to one of the following." call :dk_color %Gray% "You can change the Edition [%osedition%] [%winbuild%] to one of the following."
%line% %line%
echo: echo:
for %%A in (%_ntarget%) do ( for %%A in (%_ntarget%) do (
set /a counter+=1 set /a counter+=1
if %winbuild% GEQ 10240 (
echo "%_ptarget%" | find /i "%%A" 1>nul && (
set note=1
call :dk_color2 %_White% "[!counter!] " %Magenta% "%%A"
) || (
echo [!counter!] %%A echo [!counter!] %%A
)
) else (
echo [!counter!] %%A
)
set targetedition!counter!=%%A set targetedition!counter!=%%A
) )
%line% %line%
echo: echo:
echo [0] Exit echo [0] %_exitmsg%
echo: echo:
if defined note (
echo Note: CBS Upgrade Method is available for Purple colored editions.
echo:
)
call :dk_color %_Green% "Enter option number in keyboard, and press "Enter":" call :dk_color %_Green% "Enter option number in keyboard, and press "Enter":"
set /p inpt= set /p inpt=
if "%inpt%"=="" goto cedmenu2 if "%inpt%"=="" goto cedmenu2
@ -305,6 +338,42 @@ if %verified%==0 goto cedmenu2
::======================================================================================================================================== ::========================================================================================================================================
cls
if %winbuild% GEQ 10240 (
echo "%_ptarget%" | find /i "%targetedition%" 1>nul && (
echo "%_dtarget%" | find /i "%targetedition%" 1>nul && (
echo:
%line%
echo:
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
echo [1] DISM Method [Recommended]
) else (
echo [1] Changepk Method [Recommended]
)
echo:
echo [2] CBS Upgrade Method [Alternative]
echo:
echo [0] Go back
%line%
echo:
echo Enter a menu option in the Keyboard:
choice /C:120 /N
set _el=!errorlevel!
if !_el!==3 goto :cedmenu2
if !_el!==2 goto :cbsmethod
if !_el!==1 REM
)
)
) else (
goto :cbsmethod
)
echo "%_ptarget%" | find /i "%targetedition%" 1>nul && (
echo "%_dtarget%" | find /i "%targetedition%" 1>nul || (
goto :cbsmethod
)
)
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
goto :ced_change_server goto :ced_change_server
) )
@ -313,7 +382,6 @@ cls
set key= set key=
set _chan= set _chan=
set _changepk=0 set _changepk=0
set "keyflow=Retail Volume:MAK Volume:GVLK OEM:NONSLP OEM:DM"
:: Check if changepk.exe or slmgr.vbs is required for edition upgrade :: Check if changepk.exe or slmgr.vbs is required for edition upgrade
@ -327,17 +395,23 @@ set _changepk=1
) )
) )
if %winbuild% LEQ 19044 call :changeeditiondata if %_changepk%==1 (
set "keyflow=Retail Volume:MAK Volume:GVLK OEM:NONSLP OEM:DM"
) else (
set "keyflow=Retail OEM:NONSLP OEM:DM Volume:MAK Volume:GVLK"
)
if not defined key call :ced_targetSKU %targetedition% if not defined key call :ced_targetSKU %targetedition%
if not defined key if defined targetSKU call :ced_windowskey if not defined key if defined targetSKU call :ced_windowskey
if defined key if defined pkeychannel set _chan=%pkeychannel% if defined key if defined pkeychannel set _chan=%pkeychannel%
if not defined key call :changeeditiondata
if not defined key ( if not defined key (
%eline% %eline%
echo [%targetedition% ^| %winbuild%] echo [%targetedition% ^| %winbuild%]
echo Unable to get product key from pkeyhelper.dll echo Unable to get product key from pkeyhelper.dll
echo Make sure you are using updated version of the script echo Make sure you are using updated version of the script.
echo https://massgrave.dev
goto ced_done goto ced_done
) )
@ -348,8 +422,6 @@ goto ced_done
:: Changing from Core to Non-Core & Changing editions in Windows build older than 17134 requires "changepk /productkey" method and restart :: Changing from Core to Non-Core & Changing editions in Windows build older than 17134 requires "changepk /productkey" method and restart
:: In other cases, editions can be changed instantly with "slmgr /ipk" :: In other cases, editions can be changed instantly with "slmgr /ipk"
:ced_loop
cls cls
if %_changepk%==1 ( if %_changepk%==1 (
echo "%_chan%" | find /i "OEM" >NUL && ( echo "%_chan%" | find /i "OEM" >NUL && (
@ -358,10 +430,17 @@ echo [%osedition%] can not be changed to [%targetedition%] Edition due to lack o
echo Non-OEM keys are required to change from Core to Non-Core Editions. echo Non-OEM keys are required to change from Core to Non-Core Editions.
goto ced_done goto ced_done
) )
for %%a in (dns.msftncsi.com,www.microsoft.com,one.one.one.one,resolver1.opendns.com) do ( )
:ced_loop
cls
if %_changepk%==1 (
for %%a in (l.root-servers.net resolver1.opendns.com download.windowsupdate.com google.com) do (
for /f "delims=[] tokens=2" %%# in ('ping -n 1 %%a') do ( for /f "delims=[] tokens=2" %%# in ('ping -n 1 %%a') do (
if not [%%#]==[] ( if not [%%#]==[] (
%eline% %eline%
echo Internet needs to be disconnected to change edition [%osedition%] to [%targetedition%]
echo Disconnect the Internet and then press any key... echo Disconnect the Internet and then press any key...
pause >nul pause >nul
goto ced_loop goto ced_loop
@ -375,12 +454,17 @@ echo Changing the Current Edition [%osedition%] to [%targetedition%]
echo: echo:
if %_changepk%==1 ( if %_changepk%==1 (
call :dk_color %Green% "You can safely ignore if error appears in the upgrade Window." call :dk_color %Magenta% "Notes-"
call :dk_color %Red% "But in that case you must manually reboot the system."
echo: echo:
call :dk_color %Magenta% "Important - Save your work before continue, system will auto reboot." echo - You can safely ignore if error appears in the upgrade Window,
echo but in that case you must manually reboot the system.
echo: echo:
choice /C:21 /N /M "[1] Continue [2] Exit : " echo - Save your work before continue, system will auto restart.
echo - You can connect to Internet after the system restart.
echo:
echo - You will need to activate with HWID option once the edition is changed.
echo:
choice /C:21 /N /M "[1] Continue [2] %_exitmsg% : "
if !errorlevel!==1 exit /b if !errorlevel!==1 exit /b
) )
@ -419,6 +503,34 @@ goto ced_done
::======================================================================================================================================== ::========================================================================================================================================
:cbsmethod
cls
mode con cols=105 lines=32
%nul% %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
echo:
echo Changing the Current Edition [%osedition%] to [%targetedition%]
echo:
call :dk_color %Magenta% "Important - Save your work before continue, system will auto reboot."
if %winbuild% GEQ 17034 if %targetedition%==Professional echo - Enterprise Key will be installed instead of Pro, you can quickly change to Pro later.
echo:
choice /C:01 /N /M "[1] Continue [0] %_exitmsg% : "
if %errorlevel%==1 exit /b
echo:
echo Initializing...
echo:
if %_stg%==0 (set stage=) else (set stage=-StageCurrent)
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -SetEdition %targetedition% %stage%;"
echo:
%line%
goto ced_done
::========================================================================================================================================
:ced_change_server :ced_change_server
cls cls
@ -438,7 +550,8 @@ if not defined key (
%eline% %eline%
echo [%targetedition% ^| %winbuild%] echo [%targetedition% ^| %winbuild%]
echo Unable to get product key from pkeyhelper.dll echo Unable to get product key from pkeyhelper.dll
echo Make sure you are using updated version of the script echo Make sure you are using updated version of the script.
echo https://massgrave.dev
goto ced_done goto ced_done
) )
@ -459,7 +572,7 @@ call :dk_color %Magenta% "Make sure to restart the system."
:ced_done :ced_done
echo: echo:
call :dk_color %_Yellow% "Press any key to exit..." call :dk_color %_Yellow% "Press any key to %_exitmsg%..."
pause >nul pause >nul
exit /b exit /b
@ -483,22 +596,6 @@ if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISE
%chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a")) %chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a"))
exit /b exit /b
:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
:dk_product
set winos=
set d1=[DllImport(\"winbrand\",CharSet=CharSet.Unicode)]public static extern string BrandingFormatString(string s);
set d2=$AP=Add-Type -Member '%d1%' -Name D1 -PassThru; $AP::BrandingFormatString('%%WINDOWS_LONG%%')
for /f "delims=" %%s in ('"%psc% %d2%"') do if not errorlevel 1 (set winos=%%s)
echo "%winos%" | find /i "Windows" 1>nul || (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName 2^>nul') do set "winos=%%b"
if %winbuild% GEQ 22000 (
set winos=!winos:Windows 10=Windows 11!
)
)
exit /b
:: Check wmic.exe :: Check wmic.exe
:dk_ckeckwmic :dk_ckeckwmic
@ -509,51 +606,32 @@ wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "com
) )
exit /b exit /b
:dk_initial :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
echo: :dk_product
echo Initializing...
:: Check and enable WinMgmt, sppsvc services if required call :dk_reflection
for %%# in (WinMgmt sppsvc) do ( set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
for /f "skip=2 tokens=2*" %%a in ('reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v Start 2^>nul') do if /i %%b NEQ 0x2 ( set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%')
echo:
echo Enabling %%# service... set winos=
if /i %%#==sppsvc sc config %%# start= delayed-auto %nul% || echo Failed for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s)
if /i %%#==WinMgmt sc config %%# start= auto %nul% || echo Failed echo "%winos%" | find /i "Windows" 1>nul || (
) for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName 2^>nul') do set "winos=%%b"
sc start %%# %nul% if %winbuild% GEQ 22000 (
if !errorlevel! NEQ 1056 if !errorlevel! NEQ 0 ( set winos=!winos:Windows 10=Windows 11!
echo:
echo Starting %%# service...
sc start %%#
echo:
call :dk_color %Red% "Failed to start [%%#] service, rest of the process may take a long time..."
) )
) )
exit /b
:: Check WMI and SPP Errors :: Common lines used in PowerShell reflection code
call :dk_ckeckwmic :dk_reflection
set e_wmi= set ref=$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1);
set e_wmispp= set ref=%ref% $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False);
call :dk_actids set ref=%ref% $TypeBuilder = $ModuleBuilder.DefineType(0);
if not defined applist (
net stop sppsvc /y %nul%
cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul%
if !errorlevel! NEQ 0 cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul%
call :dk_refresh
if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "computersystem" 1>nul
if %_wmic% EQU 0 %psc% "Get-CIMInstance -Class Win32_ComputerSystem | Select-Object -Property CreationClassName" 2>nul | find /i "computersystem" 1>nul
if !errorlevel! NEQ 0 set e_wmi=1
if defined e_wmi (set e_wmispp=WMI, SPP) else (set e_wmispp=SPP)
call :dk_actids
)
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -563,24 +641,30 @@ exit /b
:dk_pkey :dk_pkey
call :dk_reflection
set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SkuGetProductKeyForEdition', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([int], [String], [String].MakeByRefType(), [String].MakeByRefType()), 1, 3);
set d1=%d1% $out = ''; [void]$TypeBuilder.CreateType()::SkuGetProductKeyForEdition(%1, %2, [ref]$out, [ref]$null); $out
set pkey= set pkey=
set d1=[DllImport(\"pkeyhelper.dll\",CharSet=CharSet.Unicode)]public static extern int SkuGetProductKeyForEdition(int e, string c, out string k, out string p); for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkey=%%a)
set d2=$AP=Add-Type -Member '%d1%' -Name D1 -PassThru; $k=''; $null=$AP::SkuGetProductKeyForEdition(%1, %2, [ref]$k, [ref]$null); $k
for /f %%a in ('%psc% "%d2%"') do if not errorlevel 1 (set pkey=%%a)
exit /b exit /b
:: Get channel name for the key which was extracted from pkeyhelper.dll :: Get channel name for the key which was extracted from pkeyhelper.dll
:dk_pkeychannel :dk_pkeychannel
set k=%1 set k=%1
set pkeychannel= set m=[Runtime.InteropServices.Marshal]
set p=%SystemRoot%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms set p=%SystemRoot%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms
set m=[System.Runtime.InteropServices.Marshal]
set d1=[DllImport(\"PidGenX.dll\",CharSet=CharSet.Unicode)]public static extern int PidGenX(string k,string p,string m,int u,IntPtr i,IntPtr d,IntPtr f); set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('PidGenX', 'pidgenx.dll', 'Public, Static', 1, [int], @([String], [String], [String], [int], [IntPtr], [IntPtr], [IntPtr]), 1, 3);
set d2=$AP=Add-Type -Member '%d1%' -Name D1 -PassThru; $k='%k%'; $p='%p%'; $r=[byte[]]::new(0x04F8); $r[0]=0xF8; $r[1]=0x04; $f=%m%::AllocHGlobal(1272); %m%::Copy($r,0,$f,1272); set d1=%d1% $r = [byte[]]::new(0x04F8); $r[0] = 0xF8; $r[1] = 0x04; $f = %m%::AllocHGlobal(0x04F8); %m%::Copy($r, 0, $f, 0x04F8);
set d3=%d2% [void]$AP::PidGenX($k,$p,\"00000\",0,0,0,$f); %m%::Copy($f,$r,0,1272); %m%::FreeHGlobal($f); [System.Text.Encoding]::Unicode.GetString($r, 1016, 128).Replace('0','') set d1=%d1% [void]$TypeBuilder.CreateType()::PidGenX('%k%', '%p%', '00000', 0, 0, 0, $f); %m%::Copy($f, $r, 0, 0x04F8); %m%::FreeHGlobal($f); [Text.Encoding]::Unicode.GetString($r, 1016, 128)
for /f %%a in ('%psc% "%d3%"') do if not errorlevel 1 (set pkeychannel=%%a)
set pkeychannel=
for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkeychannel=%%a)
exit /b exit /b
:ced_windowskey :ced_windowskey
@ -603,9 +687,13 @@ exit /b
set k=%1 set k=%1
set targetSKU= set targetSKU=
for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b
set d1=[DllImport(\"pkeyhelper.dll\",CharSet=CharSet.Unicode)]public static extern int GetEditionIdFromName(string e, out int s);
set d2=$AP=Add-Type -Member '%d1%' -Name D1 -PassThru; $s=0; $null=$AP::GetEditionIdFromName('%k%', [ref]$s); $s call :dk_reflection
for /f %%a in ('%psc% "%d2%"') do if not errorlevel 1 (set targetSKU=%%a)
set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('GetEditionIdFromName', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([String], [int].MakeByRefType()), 1, 3);
set d1=%d1% $out = 0; [void]$TypeBuilder.CreateType()::GetEditionIdFromName('%k%', [ref]$out); $out
for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set targetSKU=%%a)
if "%targetSKU%"=="0" set targetSKU= if "%targetSKU%"=="0" set targetSKU=
exit /b exit /b
@ -631,6 +719,231 @@ exit /b
::======================================================================================================================================== ::========================================================================================================================================
:: https://github.com/Gamers-Against-Weed/Set-WindowsCbsEdition
:cbsxml:[
param (
[Parameter()]
[String]$SetEdition,
[Parameter()]
[Switch]$GetTargetEditions,
[Parameter()]
[Switch]$StageCurrent
)
function Get-AssemblyIdentity {
param (
[String]$PackageName
)
$PackageName = [String]$PackageName
$packageData = ($PackageName -split '~')
if($packageData[3] -eq '') {
$packageData[3] = 'neutral'
}
return "<assemblyIdentity name=`"$($packageData[0])`" version=`"$($packageData[4])`" processorArchitecture=`"$($packageData[2])`" publicKeyToken=`"$($packageData[1])`" language=`"$($packageData[3])`" />"
}
function Get-SxsName {
param (
[String]$PackageName
)
$name = ($PackageName -replace '[^A-z0-9\-\._]', '')
if($name.Length -gt 40) {
$name = ($name[0..18] -join '') + '\.\.' + ($name[-19..-1] -join '')
}
return $name.ToLower()
}
function Find-EditionXmlInSxs {
param (
[String]$Edition
)
$candidates = @($Edition, 'Client', 'Server')
$winSxs = $Env:SystemRoot + '\WinSxS'
$allInSxs = Get-ChildItem -Path $winSxs | select Name
foreach($candidate in $candidates) {
$name = Get-SxsName -PackageName "Microsoft-Windows-Editions-$candidate"
$packages = $allInSxs | where name -Match ('^.*_'+$name+'_31bf3856ad364e35')
if($packages.Length -eq 0) {
continue
}
$package = $packages[-1].Name
$testPath = $winSxs + "\$package\" + $Edition + 'Edition.xml'
if(Test-Path -Path $testPath -PathType Leaf) {
return $testPath
}
}
return $null
}
function Find-EditionXml {
param (
[String]$Edition
)
$servicingEditions = $Env:SystemRoot + '\servicing\Editions'
$editionXml = $Edition + 'Edition.xml'
$editionXmlInServicing = $servicingEditions + '\' + $editionXml
if(Test-Path -Path $editionXmlInServicing -PathType Leaf) {
return $editionXmlInServicing
}
return Find-EditionXmlInSxs -Edition $Edition
}
function Write-UpgradeCandidates {
param (
[HashTable]$InstallCandidates
)
$editionCount = 0
Write-Host 'Editions that can be upgraded to:'
foreach($candidate in $InstallCandidates.Keys) {
Write-Host "Target Edition : $candidate"
$editionCount++
}
if($editionCount -eq 0) {
Write-Host '(no editions are available)'
}
}
function Write-UpgradeXml {
param (
[Array]$RemovalCandidates,
[Array]$InstallCandidates,
[Boolean]$Stage
)
$removeAction = 'remove'
if($Stage) {
$removeAction = 'stage'
}
Write-Output '<?xml version="1.0"?>'
Write-Output '<unattend xmlns="urn:schemas-microsoft-com:unattend">'
Write-Output '<servicing>'
foreach($package in $InstallCandidates) {
Write-Output '<package action="install">'
Write-Output (Get-AssemblyIdentity -PackageName $package)
Write-Output '</package>'
}
foreach($package in $RemovalCandidates) {
Write-Output "<package action=`"$removeAction`">"
Write-Output (Get-AssemblyIdentity -PackageName $package)
Write-Output '</package>'
}
Write-Output '</servicing>'
Write-Output '</unattend>'
}
function Write-Usage {
Get-Help $script:MyInvocation.MyCommand.Path -detailed
}
$version = '1.0'
$getTargetsParam = $GetTargetEditions.IsPresent
$stageCurrentParam = $StageCurrent.IsPresent
if($SetEdition -eq '' -and ($false -eq $getTargetsParam)) {
Write-Usage
Exit 1
}
$removalCandidates = @();
$installCandidates = @{};
$packages = Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages' | select Name | where { $_.name -match '^.*\\Microsoft-Windows-.*Edition~' }
foreach($package in $packages) {
$state = (Get-ItemProperty -Path "Registry::$($package.Name)").CurrentState
$packageName = ($package.Name -split '\\')[-1]
$packageEdition = (($packageName -split 'Edition~')[0] -split 'Microsoft-Windows-')[-1]
if($state -eq 0x40) {
if($null -eq $installCandidates[$packageEdition]) {
$installCandidates[$packageEdition] = @()
}
if($false -eq ($installCandidates[$packageEdition] -contains $packageName)) {
$installCandidates[$packageEdition] = $installCandidates[$packageEdition] + @($packageName)
}
}
if((($state -eq 0x50) -or ($state -eq 0x70)) -and ($false -eq ($removalCandidates -contains $packageName))) {
$removalCandidates = $removalCandidates + @($packageName)
}
}
if($getTargetsParam) {
Write-UpgradeCandidates -InstallCandidates $installCandidates
Exit
}
if($false -eq ($installCandidates.Keys -contains $SetEdition)) {
Write-Error "The system cannot be upgraded to `"$SetEdition`""
Exit 1
}
$xmlPath = $Env:SystemRoot + '\Temp' + '\CbsUpgrade.xml'
Write-UpgradeXml -RemovalCandidates $removalCandidates `
-InstallCandidates $installCandidates[$SetEdition] `
-Stage $stageCurrentParam >$xmlPath
$editionXml = Find-EditionXml -Edition $SetEdition
if($null -eq $editionXml) {
Write-Warning 'Unable to find edition specific settings XML. Proceeding without it...'
}
Write-Host 'Starting the upgrade process. This may take a while...'
DISM.EXE /English /NoRestart /Online /Apply-Unattend:$xmlPath
$dismError = $LASTEXITCODE
Remove-Item -Path $xmlPath -Force
if(($dismError -ne 0) -and ($dismError -ne 3010)) {
Write-Error 'Failed to upgrade to the target edition'
Exit $dismError
}
if($null -ne $editionXml) {
$destination = $Env:SystemRoot + '\' + $SetEdition + '.xml'
Copy-Item -Path $editionXml -Destination $destination
DISM.EXE /English /NoRestart /Online /Apply-Unattend:$editionXml
$dismError = $LASTEXITCODE
if(($dismError -ne 0) -and ($dismError -ne 3010)) {
Write-Error 'Failed to apply edition specific settings'
Exit $dismError
}
}
Restart-Computer
:cbsxml:]
::========================================================================================================================================
:: 1st column = Generic Retail/OEM/MAK/GVLK Key :: 1st column = Generic Retail/OEM/MAK/GVLK Key
:: 2nd column = Key Type :: 2nd column = Key Type
:: 3rd column = WMI Edition ID :: 3rd column = WMI Edition ID
@ -643,44 +956,47 @@ exit /b
:changeeditiondata :changeeditiondata
set h=
for %%# in ( for %%# in (
44NYX-TKR9D-CCM2D-V6B8F-HQWWR_Volume:MAK_Enterprise 44N%h%YX-TK%h%R9D-CCM2%h%D-V6%h%B8F-HQ%h%WWR__Volume:MAK_Enterprise
D6RD9-D4N8T-RT9QX-YW6YT-FCWWJ_____Retail_Starter D6R%h%D9-D4%h%N8T-RT9Q%h%X-YW%h%6YT-FC%h%WWJ______Retail_Starter
3V6Q6-NQXCX-V8YXR-9QCYV-QPFCT_Volume:MAK_EnterpriseN 3V6%h%Q6-NQ%h%XCX-V8YX%h%R-9Q%h%CYV-QP%h%FCT__Volume:MAK_EnterpriseN
3NFXW-2T27M-2BDW6-4GHRV-68XRX_____Retail_StarterN 3NF%h%XW-2T%h%27M-2BDW%h%6-4G%h%HRV-68%h%XRX______Retail_StarterN
VK7JG-NPHTM-C97JM-9MPGT-3V66T_____Retail_Professional VK7%h%JG-NP%h%HTM-C97J%h%M-9M%h%PGT-3V%h%66T______Retail_Professional
2B87N-8KFHP-DKV6R-Y2C8J-PKCKT_____Retail_ProfessionalN 2B8%h%7N-8K%h%FHP-DKV6%h%R-Y2%h%C8J-PK%h%CKT______Retail_ProfessionalN
4CPRK-NM3K3-X6XXQ-RXX86-WXCHW_____Retail_CoreN 4CP%h%RK-NM%h%3K3-X6XX%h%Q-RX%h%X86-WX%h%CHW______Retail_CoreN
N2434-X9D7W-8PF6X-8DV9T-8TYMD_____Retail_CoreCountrySpecific N24%h%34-X9%h%D7W-8PF6%h%X-8D%h%V9T-8T%h%YMD______Retail_CoreCountrySpecific
BT79Q-G7N6G-PGBYW-4YWX6-6F4BT_____Retail_CoreSingleLanguage BT7%h%9Q-G7%h%N6G-PGBY%h%W-4Y%h%WX6-6F%h%4BT______Retail_CoreSingleLanguage
YTMG3-N6DKC-DKB77-7M9GH-8HVX7_____Retail_Core YTM%h%G3-N6%h%DKC-DKB7%h%7-7M%h%9GH-8H%h%VX7______Retail_Core
XKCNC-J26Q9-KFHD2-FKTHY-KD72Y_OEM:NONSLP_PPIPro XKC%h%NC-J2%h%6Q9-KFHD%h%2-FK%h%THY-KD%h%72Y__OEM:NONSLP_PPIPro
YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY_____Retail_Education YNM%h%GQ-8R%h%YV3-4PGQ%h%3-C8%h%XTP-7C%h%FBY______Retail_Education
84NGF-MHBT6-FXBX8-QWJK7-DRR8H_____Retail_EducationN 84N%h%GF-MH%h%BT6-FXBX%h%8-QW%h%JK7-DR%h%R8H______Retail_EducationN
KCNVH-YKWX8-GJJB9-H9FDT-6F7W2_Volume:MAK_EnterpriseS_2021 KCN%h%VH-YK%h%WX8-GJJB%h%9-H9%h%FDT-6F%h%7W2__Volume:MAK_EnterpriseS_VB
VBX36-N7DDY-M9H62-83BMJ-CPR42_Volume:MAK_EnterpriseS_2019 VBX%h%36-N7%h%DDY-M9H6%h%2-83%h%BMJ-CP%h%R42__Volume:MAK_EnterpriseS_RS5
PN3KR-JXM7T-46HM4-MCQGK-7XPJQ_Volume:MAK_EnterpriseS_2016 PN3%h%KR-JX%h%M7T-46HM%h%4-MC%h%QGK-7X%h%PJQ__Volume:MAK_EnterpriseS_RS1
DVWKN-3GCMV-Q2XF4-DDPGM-VQWWY_Volume:MAK_EnterpriseS_2015 DVW%h%KN-3G%h%CMV-Q2XF%h%4-DD%h%PGM-VQ%h%WWY__Volume:MAK_EnterpriseS_TH
RQFNW-9TPM3-JQ73T-QV4VQ-DV9PT_Volume:MAK_EnterpriseSN_2021 RQF%h%NW-9T%h%PM3-JQ73%h%T-QV%h%4VQ-DV%h%9PT__Volume:MAK_EnterpriseSN_VB
M33WV-NHY3C-R7FPM-BQGPT-239PG_Volume:MAK_EnterpriseSN_2019 M33%h%WV-NH%h%Y3C-R7FP%h%M-BQ%h%GPT-23%h%9PG__Volume:MAK_EnterpriseSN_RS5
2DBW3-N2PJG-MVHW3-G7TDK-9HKR4_Volume:MAK_EnterpriseSN_2016 2DB%h%W3-N2%h%PJG-MVHW%h%3-G7%h%TDK-9H%h%KR4__Volume:MAK_EnterpriseSN_RS1
NTX6B-BRYC2-K6786-F6MVQ-M7V2X_Volume:MAK_EnterpriseSN_2015 NTX%h%6B-BR%h%YC2-K678%h%6-F6%h%MVQ-M7%h%V2X__Volume:MAK_EnterpriseSN_TH
G3KNM-CHG6T-R36X3-9QDG6-8M8K9_____Retail_ProfessionalSingleLanguage G3K%h%NM-CH%h%G6T-R36X%h%3-9Q%h%DG6-8M%h%8K9______Retail_ProfessionalSingleLanguage
HNGCC-Y38KG-QVK8D-WMWRK-X86VK_____Retail_ProfessionalCountrySpecific HNG%h%CC-Y3%h%8KG-QVK8%h%D-WM%h%WRK-X8%h%6VK______Retail_ProfessionalCountrySpecific
DXG7C-N36C4-C4HTG-X4T3X-2YV77_____Retail_ProfessionalWorkstation DXG%h%7C-N3%h%6C4-C4HT%h%G-X4%h%T3X-2Y%h%V77______Retail_ProfessionalWorkstation
WYPNQ-8C467-V2W6J-TX4WX-WT2RQ_____Retail_ProfessionalWorkstationN WYP%h%NQ-8C%h%467-V2W6%h%J-TX%h%4WX-WT%h%2RQ______Retail_ProfessionalWorkstationN
8PTT6-RNW4C-6V7J2-C2D3X-MHBPB_____Retail_ProfessionalEducation 8PT%h%T6-RN%h%W4C-6V7J%h%2-C2%h%D3X-MH%h%BPB______Retail_ProfessionalEducation
GJTYN-HDMQY-FRR76-HVGC7-QPF8P_____Retail_ProfessionalEducationN GJT%h%YN-HD%h%MQY-FRR7%h%6-HV%h%GC7-QP%h%F8P______Retail_ProfessionalEducationN
C4NTJ-CX6Q2-VXDMR-XVKGM-F9DJC_Volume:MAK_EnterpriseG C4N%h%TJ-CX%h%6Q2-VXDM%h%R-XV%h%KGM-F9%h%DJC__Volume:MAK_EnterpriseG
46PN6-R9BK9-CVHKB-HWQ9V-MBJY8_Volume:MAK_EnterpriseGN 46P%h%N6-R9%h%BK9-CVHK%h%B-HW%h%Q9V-MB%h%JY8__Volume:MAK_EnterpriseGN
NJCF7-PW8QT-3324D-688JX-2YV66_____Retail_ServerRdsh NJC%h%F7-PW%h%8QT-3324%h%D-68%h%8JX-2Y%h%V66______Retail_ServerRdsh
V3WVW-N2PV2-CGWC3-34QGF-VMJ2C_____Retail_Cloud V3W%h%VW-N2%h%PV2-CGWC%h%3-34%h%QGF-VM%h%J2C______Retail_Cloud
NH9J3-68WK7-6FB93-4K3DF-DJ4F6_____Retail_CloudN NH9%h%J3-68%h%WK7-6FB9%h%3-4K%h%3DF-DJ%h%4F6______Retail_CloudN
2HN6V-HGTM8-6C97C-RK67V-JQPFD_____Retail_CloudE 2HN%h%6V-HG%h%TM8-6C97%h%C-RK%h%67V-JQ%h%PFD______Retail_CloudE
XQQYW-NFFMW-XJPBH-K8732-CKFFD_____OEM:DM_IoTEnterprise XQQ%h%YW-NF%h%FMW-XJPB%h%H-K8%h%732-CK%h%FFD______OEM:DM_IoTEnterprise
QPM6N-7J2WJ-P88HH-P3YRH-YY74H_OEM:NONSLP_IoTEnterpriseS QPM%h%6N-7J%h%2WJ-P88H%h%H-P3%h%YRH-YY%h%74H__OEM:NONSLP_IoTEnterpriseS_VB
K9VKN-3BGWV-Y624W-MCRMQ-BHDCD_____Retail_CloudEditionN KBN%h%8V-HF%h%GQ4-MGXV%h%D-34%h%7P6-PD%h%QGT_Volume:GVLK_IoTEnterpriseS_NI
KY7PN-VR6RX-83W6Y-6DDYQ-T6R4W_____Retail_CloudEdition K9V%h%KN-3B%h%GWV-Y624%h%W-MC%h%RMQ-BH%h%DCD______Retail_CloudEditionN
KY7%h%PN-VR%h%6RX-83W6%h%Y-6D%h%DYQ-T6%h%R4W______Retail_CloudEdition
MPB%h%3G-XN%h%BR7-CC43%h%M-FG%h%64B-F9%h%GBK______Retail_IoTEnterpriseSK
) do ( ) do (
for /f "tokens=1-4 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C ( for /f "tokens=1-4 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C (
@ -689,7 +1005,7 @@ set 4th=%%D
if not defined 4th ( if not defined 4th (
set "key=%%A" & set "_chan=%%B" set "key=%%A" & set "_chan=%%B"
) else ( ) else (
echo "%winos%" | find "%%D" 1>nul && (set "key=%%A" & set "_chan=%%B") echo "%branch%" | find "%%D" 1>nul && (set "key=%%A" & set "_chan=%%B")
) )
) )
) )
@ -701,21 +1017,21 @@ exit /b
:changeeditionserverdata :changeeditionserverdata
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" (set Cor=Cor) else (set Cor=) if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" (set Cor=Cor) else (set Cor=)
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildBranch 2^>nul') do set "branch=%%b"
:: Only RS3 and older version keys (GVLK/Generic Retail) are stored here, later ones are extracted from the system itself :: Only RS3 and older version keys (GVLK/Generic Retail) are stored here, later ones are extracted from the system itself
set h=
for %%# in ( for %%# in (
WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY_RS1_ServerStandard%Cor% WC2%h%BQ-8N%h%RM3-FDD%h%YY-2B%h%FGV-KHK%h%QY_RS1_ServerStandard%Cor%
CB7KF-BWN84-R7R2Y-793K2-8XDDG_RS1_ServerDatacenter%Cor% CB7%h%KF-BW%h%N84-R7R%h%2Y-79%h%3K2-8XD%h%DG_RS1_ServerDatacenter%Cor%
JCKRF-N37P4-C2D82-9YXRT-4M63B_RS1_ServerSolution JCK%h%RF-N3%h%7P4-C2D%h%82-9Y%h%XRT-4M6%h%3B_RS1_ServerSolution
QN4C6-GBJD2-FB422-GHWJK-GJG2R_RS1_ServerCloudStorage QN4%h%C6-GB%h%JD2-FB4%h%22-GH%h%WJK-GJG%h%2R_RS1_ServerCloudStorage
VP34G-4NPPG-79JTQ-864T4-R3MQX_RS1_ServerAzureCor VP3%h%4G-4N%h%PPG-79J%h%TQ-86%h%4T4-R3M%h%QX_RS1_ServerAzureCor
9JQNQ-V8HQ6-PKB8H-GGHRY-R62H6_RS1_ServerAzureNano 9JQ%h%NQ-V8%h%HQ6-PKB%h%8H-GG%h%HRY-R62%h%H6_RS1_ServerAzureNano
VN8D3-PR82H-DB6BJ-J9P4M-92F6J_RS1_ServerStorageStandard VN8%h%D3-PR%h%82H-DB6%h%BJ-J9%h%P4M-92F%h%6J_RS1_ServerStorageStandard
48TQX-NVK3R-D8QR3-GTHHM-8FHXC_RS1_ServerStorageWorkgroup 48T%h%QX-NV%h%K3R-D8Q%h%R3-GT%h%HHM-8FH%h%XC_RS1_ServerStorageWorkgroup
2HXDN-KRXHB-GPYC7-YCKFJ-7FVDG_RS3_ServerDatacenterACor 2HX%h%DN-KR%h%XHB-GPY%h%C7-YC%h%KFJ-7FV%h%DG_RS3_ServerDatacenterACor
PTXN8-JFHJM-4WC78-MPCBR-9W4KR_RS3_ServerStandardACor PTX%h%N8-JF%h%HJM-4WC%h%78-MP%h%CBR-9W4%h%KR_RS3_ServerStandardACor
) do ( ) do (
for /f "tokens=1-3 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C ( for /f "tokens=1-3 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C (
echo "%branch%" | find /i "%%B" 1>nul && (set "key=%%A") echo "%branch%" | find /i "%%B" 1>nul && (set "key=%%A")

View File

@ -42,10 +42,9 @@ pushd "%~dp0"
>nul findstr /rxc:".*" "%~nx0" >nul findstr /rxc:".*" "%~nx0"
if not %errorlevel%==0 ( if not %errorlevel%==0 (
echo: echo:
echo Error: This is not a correct file. It has LF line ending issue. echo Error: Script either has LF line ending issue, or it failed to read itself.
echo: echo:
echo Press any key to exit... ping 127.0.0.1 -n 6 > nul
pause >nul
popd popd
exit /b exit /b
) )

View File

@ -70,10 +70,9 @@ pushd "%~dp0"
>nul findstr /rxc:".*" "%~nx0" >nul findstr /rxc:".*" "%~nx0"
if not %errorlevel%==0 ( if not %errorlevel%==0 (
echo: echo:
echo Error: This is not a correct file. It has LF line ending issue. echo Error: Script either has LF line ending issue, or it failed to read itself.
echo: echo:
echo Press any key to exit... ping 127.0.0.1 -n 6 > nul
pause >nul
popd popd
exit /b exit /b
) )
@ -86,7 +85,9 @@ wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "Com
if %_cwmi% EQU 0 ( if %_cwmi% EQU 0 (
echo: echo:
echo Error: wmic.exe is not responding in the system. echo Error: WMI is not responding in the system.
echo:
echo In MAS, Goto Troubleshoot and run Fix WMI option.
echo: echo:
echo Press any key to exit... echo Press any key to exit...
pause >nul pause >nul
@ -362,7 +363,7 @@ exit /b
function PrintModePerPridFromRegistry function PrintModePerPridFromRegistry
{ {
$vNextRegkey = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext" $vNextRegkey = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext"
$vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction Ignore | Select-Object -ExpandProperty 'property' | Where-Object -FilterScript {$_ -Ne 'InstalledGraceKey' -And $_ -Ne 'MigrationToV5Done' -And $_ -Ne 'test' -And $_ -Ne 'unknown'} $vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction Ignore | Select-Object -ExpandProperty 'property' | Where-Object -FilterScript {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"}
If ($vNextPrids -Eq $null) If ($vNextPrids -Eq $null)
{ {
Write-Host "No registry keys found." Write-Host "No registry keys found."
@ -457,15 +458,20 @@ function PrintLicensesInformation
$license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License $license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License
$decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json $decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json
$licenseType = $decodedLicense.LicenseType $licenseType = $decodedLicense.LicenseType
$userId = $decodedLicense.Metadata.UserId If ($null -Ne $decodedLicense.ExpiresOn)
$identitiesRegkey = Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Identity\Identities\${userId}*" -ErrorAction Ignore {
$expiry = [DateTime]::Parse($decodedLicense.ExpiresOn, $null, 48)
}
Else
{
$expiry = New-Object DateTime
}
$licenseState = $null $licenseState = $null
If ((Get-Date) -Gt (Get-Date $decodedLicense.MetaData.NotAfter)) If ((Get-Date) -Gt (Get-Date $decodedLicense.MetaData.NotAfter))
{ {
$licenseState = "RFM" $licenseState = "RFM"
} }
ElseIf (($decodedLicense.ExpiresOn -Eq $null) -Or ElseIf ((Get-Date) -Lt (Get-Date $expiry))
((Get-Date) -Lt (Get-Date $decodedLicense.ExpiresOn)))
{ {
$licenseState = "Licensed" $licenseState = "Licensed"
} }
@ -483,11 +489,11 @@ function PrintLicensesInformation
Acid = $decodedLicense.Acid; Acid = $decodedLicense.Acid;
LicenseState = $licenseState; LicenseState = $licenseState;
EntitlementStatus = $decodedLicense.Status; EntitlementStatus = $decodedLicense.Status;
EntitlementExpiration = $decodedLicense.ExpiresOn;
ReasonCode = $decodedLicense.ReasonCode; ReasonCode = $decodedLicense.ReasonCode;
NotBefore = $decodedLicense.Metadata.NotBefore; NotBefore = $decodedLicense.Metadata.NotBefore;
NotAfter = $decodedLicense.Metadata.NotAfter; NotAfter = $decodedLicense.Metadata.NotAfter;
NextRenewal = $decodedLicense.Metadata.RenewAfter; NextRenewal = $decodedLicense.Metadata.RenewAfter;
Expiration = $decodedLicense.ExpiresOn;
TenantId = $decodedLicense.Metadata.TenantId; TenantId = $decodedLicense.Metadata.TenantId;
} | ConvertTo-Json } | ConvertTo-Json
} }
@ -502,11 +508,11 @@ function PrintLicensesInformation
DeviceId = $decodedLicense.Metadata.DeviceId; DeviceId = $decodedLicense.Metadata.DeviceId;
LicenseState = $licenseState; LicenseState = $licenseState;
EntitlementStatus = $decodedLicense.Status; EntitlementStatus = $decodedLicense.Status;
EntitlementExpiration = $decodedLicense.ExpiresOn;
ReasonCode = $decodedLicense.ReasonCode; ReasonCode = $decodedLicense.ReasonCode;
NotBefore = $decodedLicense.Metadata.NotBefore; NotBefore = $decodedLicense.Metadata.NotBefore;
NotAfter = $decodedLicense.Metadata.NotAfter; NotAfter = $decodedLicense.Metadata.NotAfter;
NextRenewal = $decodedLicense.Metadata.RenewAfter; NextRenewal = $decodedLicense.Metadata.RenewAfter;
Expiration = $decodedLicense.ExpiresOn;
TenantId = $decodedLicense.Metadata.TenantId; TenantId = $decodedLicense.Metadata.TenantId;
} | ConvertTo-Json } | ConvertTo-Json
} }

View File

@ -53,10 +53,9 @@ pushd "%~dp0"
>nul findstr /rxc:".*" "%~nx0" >nul findstr /rxc:".*" "%~nx0"
if not %errorlevel%==0 ( if not %errorlevel%==0 (
echo: echo:
echo Error: This is not a correct file. It has LF line ending issue. echo Error: Script either has LF line ending issue, or it failed to read itself.
echo: echo:
echo Press any key to exit... ping 127.0.0.1 -n 6 > nul
pause >nul
popd popd
exit /b exit /b
) )
@ -114,22 +113,12 @@ goto done2
::======================================================================================================================================== ::========================================================================================================================================
:: Check desktop location :: Fix for the special characters limitation in path name
set desktop= set desktop=
for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do call set "desktop=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do call set "desktop=%%b"
if not defined desktop for /f "delims=" %%a in ('%psc% "& {write-host $([Environment]::GetFolderPath('Desktop'))}"') do call set "desktop=%%a" if not defined desktop for /f "delims=" %%a in ('%psc% "& {write-host $([Environment]::GetFolderPath('Desktop'))}"') do call set "desktop=%%a"
if not defined desktop (
%eline%
echo Desktop location was not detected, aborting...
goto done2
)
::========================================================================================================================================
:: Fix for the special characters limitation in path name
set "_work=%~dp0" set "_work=%~dp0"
if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%" if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%"
@ -137,6 +126,7 @@ set "_batf=%~f0"
set "_batp=%_batf:'=''%" set "_batp=%_batf:'=''%"
set "_pdesk=%desktop:'=''%" set "_pdesk=%desktop:'=''%"
set _PSarg="""%~f0""" -el %_args%
set "_ttemp=%temp%" set "_ttemp=%temp%"
set "_dir=%desktop%\$OEM$\$$\Setup\Scripts" set "_dir=%desktop%\$OEM$\$$\Setup\Scripts"
@ -145,14 +135,6 @@ setlocal EnableDelayedExpansion
::======================================================================================================================================== ::========================================================================================================================================
if not exist "!desktop!\" (
%eline%
echo Desktop location was not detected, aborting...
goto done2
)
::========================================================================================================================================
echo "!_batf!" | find /i "!_ttemp!" 1>nul && ( echo "!_batf!" | find /i "!_ttemp!" 1>nul && (
if /i not "!_work!"=="!_ttemp!" ( if /i not "!_work!"=="!_ttemp!" (
%eline% %eline%
@ -166,7 +148,27 @@ goto done2
::======================================================================================================================================== ::========================================================================================================================================
mode 66, 26 :: Elevate script as admin and pass arguments and preventing loop
>nul fltmc || (
if not defined _elev %nul% %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b
%eline%
echo This script require administrator privileges.
echo To do so, right click on this script and select 'Run as administrator'.
goto done2
)
::========================================================================================================================================
if not exist "!desktop!\" (
%eline%
echo Desktop location was not detected, aborting...
goto done2
)
::========================================================================================================================================
mode con cols=78 lines=30
if exist "!desktop!\$OEM$\" ( if exist "!desktop!\$OEM$\" (
echo _____________________________________________________ echo _____________________________________________________
@ -176,14 +178,9 @@ echo _____________________________________________________
goto done2 goto done2
) )
set HWID_Activation.cmd=HWID-KMS38_Activation\HWID_Activation.cmd set HWID_Activation.cmd=Activators\HWID_Activation.cmd
set KMS38_Activation.cmd=HWID-KMS38_Activation\KMS38_Activation.cmd set KMS38_Activation.cmd=Activators\KMS38_Activation.cmd
set ClipUp.exe=HWID-KMS38_Activation\BIN\ClipUp.exe set Online_KMS_Activation.cmd=Activators\Online_KMS_Activation.cmd
set gatherosstate.exe=HWID-KMS38_Activation\BIN\gatherosstate.exe
set Activate.cmd=Online_KMS_Activation\Activate.cmd
set cleanosppx64.exe=Online_KMS_Activation\BIN\cleanosppx64.exe
set cleanosppx86.exe=Online_KMS_Activation\BIN\cleanosppx86.exe
pushd "!_work!" pushd "!_work!"
@ -191,11 +188,7 @@ set _nofile=
for %%# in ( for %%# in (
%HWID_Activation.cmd% %HWID_Activation.cmd%
%KMS38_Activation.cmd% %KMS38_Activation.cmd%
%ClipUp.exe% %Online_KMS_Activation.cmd%
%gatherosstate.exe%
%Activate.cmd%
%cleanosppx64.exe%
%cleanosppx86.exe%
) do ( ) do (
if not exist "%%#" set _nofile=1 if not exist "%%#" set _nofile=1
) )
@ -215,25 +208,27 @@ goto done2
:Menu :Menu
cls cls
mode con cols=78 lines=30
echo: echo:
echo: echo:
echo: echo:
echo: echo:
echo: Extract $OEM$ folder on the desktop
echo: ________________________________________________________
echo: echo:
echo: [1] HWID echo: Extract $OEM$ folder on the desktop
echo: [2] KMS38 echo: ________________________________________________________
echo: [3] Online KMS
echo: echo:
echo: [4] HWID ^(Windows^) ^+ Online KMS ^(Office^) echo: [1] HWID
echo: [5] KMS38 ^(Windows^) ^+ Online KMS ^(Office^) echo: [2] KMS38
echo: [3] Online KMS
echo: echo:
echo: [6] Exit echo: [4] HWID ^(Windows^) ^+ Online KMS ^(Office^)
echo: ________________________________________________________ echo: [5] KMS38 ^(Windows^) ^+ Online KMS ^(Office^)
echo: echo:
call :ex_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard [1,2,3,4,5,6]" echo: [0] Exit
choice /C:123456 /N echo: ________________________________________________________
echo:
call :ex_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard [1,2,3,4,5,0]"
choice /C:123450 /N
set _erl=%errorlevel% set _erl=%errorlevel%
if %_erl%==6 exit /b if %_erl%==6 exit /b
@ -249,14 +244,18 @@ goto :Menu
:hwid :hwid
cls cls
call :prep md "!desktop!\$OEM$\$$\Setup\Scripts"
call :hwidprep pushd "!_work!"
call :pop_d copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul%
popd
call :export hwid_setup call :export hwid_setup
call :hwidprep2
set _error=
if not exist "!_dir!\HWID_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound if defined _error goto errorfound
set "_oem=HWID"
set oem=HWID
goto done goto done
:hwid_setup: :hwid_setup:
@ -264,7 +263,7 @@ goto done
fltmc >nul || exit /b fltmc >nul || exit /b
start /b /wait cmd /c "%~dp0HWID_Activation.cmd" /a start /b /wait cmd /c "%~dp0HWID_Activation.cmd" /HWID
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
@ -275,14 +274,18 @@ cd \
:kms38 :kms38
cls cls
call :prep md "!desktop!\$OEM$\$$\Setup\Scripts"
call :kms38prep pushd "!_work!"
call :pop_d copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul%
popd
call :export kms38_setup call :export kms38_setup
call :kms38prep2
set _error=
if not exist "!_dir!\KMS38_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound if defined _error goto errorfound
set "_oem=KMS38"
set oem=KMS38
goto done goto done
:kms38_setup: :kms38_setup:
@ -290,7 +293,7 @@ goto done
fltmc >nul || exit /b fltmc >nul || exit /b
start /b /wait cmd /c "%~dp0KMS38_Activation.cmd" /a start /b /wait cmd /c "%~dp0KMS38_Activation.cmd" /KMS38
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
@ -301,14 +304,18 @@ cd \
:kms :kms
cls cls
call :prep md "!desktop!\$OEM$\$$\Setup\Scripts"
call :kmsprep pushd "!_work!"
call :pop_d copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul%
popd
call :export kms_setup call :export kms_setup
call :kmsprep2
if defined _kerror goto errorfound set _error=
set "_oem=Online KMS" if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound
set oem=Online KMS
goto done goto done
:kms_setup: :kms_setup:
@ -316,8 +323,7 @@ goto done
fltmc >nul || exit /b fltmc >nul || exit /b
start /b /wait cmd /c "%~dp0Activate.cmd" /rat start /b /wait cmd /c "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-WindowsOffice
start /b /wait cmd /c "%~dp0Activate.cmd" /wo
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
@ -328,17 +334,20 @@ cd \
:hwid_kms :hwid_kms
cls cls
call :prep md "!desktop!\$OEM$\$$\Setup\Scripts"
call :hwidprep pushd "!_work!"
call :kmsprep copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul%
call :pop_d copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul%
popd
call :export hwid_kms_setup call :export hwid_kms_setup
call :hwidprep2
call :kmsprep2
set _error=
if not exist "!_dir!\HWID_Activation.cmd" set _error=1
if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound if defined _error goto errorfound
if defined _kerror goto errorfound
set "_oem=HWID [Windows] + Online KMS [Office]" set oem=HWID [Windows] + Online KMS [Office]
goto done goto done
:hwid_kms_setup: :hwid_kms_setup:
@ -346,10 +355,9 @@ goto done
fltmc >nul || exit /b fltmc >nul || exit /b
start /b /wait cmd /c "%~dp0HWID_Activation.cmd" /a start /b /wait cmd /c "%~dp0HWID_Activation.cmd" /HWID
start /b /wait cmd /c "%~dp0Activate.cmd" /rat start /b /wait cmd /c "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-Office
start /b /wait cmd /c "%~dp0Activate.cmd" /o
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
@ -360,17 +368,20 @@ cd \
:kms38_kms :kms38_kms
cls cls
call :prep md "!desktop!\$OEM$\$$\Setup\Scripts"
call :kms38prep pushd "!_work!"
call :kmsprep copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul%
call :pop_d copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul%
popd
call :export kms38_kms_setup call :export kms38_kms_setup
call :kms38prep2
call :kmsprep2
set _error=
if not exist "!_dir!\KMS38_Activation.cmd" set _error=1
if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound if defined _error goto errorfound
if defined _kerror goto errorfound
set "_oem=KMS38 [Windows] + Online KMS [Office]" set oem=KMS38 [Windows] + Online KMS [Office]
goto done goto done
:kms38_kms_setup: :kms38_kms_setup:
@ -378,10 +389,9 @@ goto done
fltmc >nul || exit /b fltmc >nul || exit /b
start /b /wait cmd /c "%~dp0KMS38_Activation.cmd" /a start /b /wait cmd /c "%~dp0KMS38_Activation.cmd" /KMS38
start /b /wait cmd /c "%~dp0Activate.cmd" /rat start /b /wait cmd /c "%~dp0Online_KMS_Activation.cmd" /KMS-ActAndRenewalTask /KMS-Office
start /b /wait cmd /c "%~dp0Activate.cmd" /o
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
@ -397,11 +407,16 @@ goto :done2
:done :done
echo _______________________________________________________ echo ______________________________________________________________
echo: echo:
call :ex_color %Magenta% "%_oem%" call :ex_color %Magenta% "%oem%"
call :ex_color %Green% "$OEM$ folder is successfully created on the Desktop." call :ex_color %Green% "$OEM$ folder is successfully created on the Desktop."
echo _______________________________________________________ echo "%oem%" | find /i "38" %nul% && (
echo:
echo To KMS38 activate Server Cor/Acor editions ^(No GUI Versions^),
echo Check this page https://massgrave.dev/oem-folder
)
echo ______________________________________________________________
:done2 :done2
@ -412,88 +427,6 @@ exit /b
::======================================================================================================================================== ::========================================================================================================================================
:prep
pushd "!desktop!"
md "!desktop!\$OEM$\$$\Setup\Scripts\BIN"
pushd "!_work!"
exit /b
:hwidprep
copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul%
copy /y /b "%gatherosstate.exe%" "!_dir!\BIN\gatherosstate.exe" %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%
exit /b
:kmsprep
copy /y /b "%Activate.cmd%" "!_dir!\Activate.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
set _error=
pushd "!_dir!\"
for %%# in (
HWID_Activation.cmd
BIN\gatherosstate.exe
SetupComplete.cmd
) do (
if not exist "%%#" set _error=1
)
popd
exit /b
:kms38prep2
set _error=
pushd "!_dir!\"
for %%# in (
KMS38_Activation.cmd
BIN\ClipUp.exe
BIN\gatherosstate.exe
SetupComplete.cmd
) do (
if not exist "%%#" set _error=1
)
popd
exit /b
:kmsprep2
set _kerror=
pushd "!_dir!\"
for %%# in (
Activate.cmd
BIN\cleanosppx64.exe
BIN\cleanosppx86.exe
SetupComplete.cmd
) do (
if not exist "%%#" set _kerror=1
)
popd
exit /b
:pop_d
popd
popd
exit /b
::========================================================================================================================================
:: Extract the text from batch script without character and file encoding issue :: Extract the text from batch script without character and file encoding issue
:export :export

View File

@ -1,22 +0,0 @@
=================================================================================
File Details:
=================================================================================
- ClipUp.exe (x64)
SHA-1: 48D928B1BEC25A56FE896C430C2C034B7866AA7A
Taken from Windows server 2016 x64 ISO
https://www.microsoft.com/en-us/evalcenter/
- gatherosstate.exe (x86)
SHA-1: FABB5A0FC1E6A372219711152291339AF36ED0B5
Taken from Windows 10 Version 1607 ADK (Section: User State Migration Tool)
https://go.microsoft.com/fwlink/p/?LinkId=526740
_________________________________________________________________________________
- All files are original Microsoft's files.
- ClipUp.exe is required for KMS38 activation of Server Cor/Acor editions.
=================================================================================

View File

@ -14,7 +14,7 @@
:: For unattended mode, run the script with /u parameter. :: For unattended mode, run the script with "/Insert-HWID-Key" parameter
@ -56,10 +56,9 @@ pushd "%~dp0"
>nul findstr /rxc:".*" "%~nx0" >nul findstr /rxc:".*" "%~nx0"
if not %errorlevel%==0 ( if not %errorlevel%==0 (
echo: echo:
echo Error: This is not a correct file. It has LF line ending issue. echo Error: Script either has LF line ending issue, or it failed to read itself.
echo: echo:
echo Press any key to exit... ping 127.0.0.1 -n 6 > nul
pause >nul
popd popd
exit /b exit /b
) )
@ -69,7 +68,7 @@ popd
cls cls
color 07 color 07
title Install Windows Retail/OEM/MAK Key title Install Windows HWID Key
set _args= set _args=
set _elev= set _elev=
@ -80,7 +79,7 @@ if defined _args set _args=%_args:"=%
if defined _args ( if defined _args (
for %%A in (%_args%) do ( for %%A in (%_args%) do (
if /i "%%A"=="-el" set _elev=1 if /i "%%A"=="-el" set _elev=1
if /i "%%A"=="/u" set _unattended=1 if /i "%%A"=="/Insert-HWID-Key" set _unattended=1
) )
) )
@ -111,13 +110,20 @@ set "_Yellow="Black" "Yellow""
set "nceline=echo: &echo ==== ERROR ==== &echo:" set "nceline=echo: &echo ==== ERROR ==== &echo:"
set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:" set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:"
set "line=echo ___________________________________________________________________________________________" set "line=echo ___________________________________________________________________________________________"
if %~z0 GEQ 200000 (set "_exitmsg=Go back") else (set "_exitmsg=Exit")
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% LSS 10240 ( if %winbuild% LSS 10240 (
%eline% %eline%
echo Unsupported OS version detected. echo Unsupported OS version detected.
echo Project is supported for Windows 10/11. echo This option is supported only for Windows 10/11.
goto ins_done
)
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
%eline%
echo HWID Activation is not supported for Windows Server.
goto ins_done goto ins_done
) )
@ -160,7 +166,7 @@ goto ins_done
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul% reg query HKU\S-1-5-19 || ( >nul fltmc || (
if not defined _elev %nul% %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b if not defined _elev %nul% %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b
%eline% %eline%
echo This script require administrator privileges. echo This script require administrator privileges.
@ -172,13 +178,11 @@ goto ins_done
cls cls
mode 98, 30 mode 98, 30
echo:
call :dk_initial echo Initializing...
:: Check product name
cls
call :dk_product call :dk_product
call :dk_ckeckwmic
call :dk_actids
::======================================================================================================================================== ::========================================================================================================================================
@ -206,34 +210,23 @@ goto ins_done
:: Detect key :: Detect key
set key= set key=
set pkey= set channel=
set _chan= set actidnotfound=
if defined applist call :hwiddata attempt1 for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildBranch 2^>nul') do set "branch=%%b"
if not defined key call :hwiddata attempt2
set pkey= if defined applist call :hwidkey key attempt1
if not defined key call :dk_hwidkey %nul% if not defined key call :hwidkey key attempt2
if not defined key ( if not defined key (
%eline% %eline%
%psc% $ExecutionContext.SessionState.LanguageMode 2>nul | find /i "Full" 1>nul || ( echo [%winos% ^| %winbuild% ^| SKU:%osSKU%]
echo PowerShell is not responding properly. echo Unable to find this product in the HWID supported product list.
echo: echo Make sure you are using updated version of the script.
) echo https://massgrave.dev
echo Unable to find HWID key for [%winos% ^| SKU:%osSKU% ^| %winbuild%]
echo Make sure you are using updated version of the script
echo:
if not "%regSKU%"=="%wmiSKU%" (
echo Difference Found In SKU Value- WMI:%wmiSKU% Reg:%regSKU%
echo Restart the system and try again.
)
goto ins_done goto ins_done
) )
if defined key call :dk_pkeychannel %key%
if defined pkeychannel set _chan=%pkeychannel% Key
::======================================================================================================================================== ::========================================================================================================================================
if %_unattended%==1 goto insertkey if %_unattended%==1 goto insertkey
@ -241,19 +234,17 @@ if %_unattended%==1 goto insertkey
cls cls
%line% %line%
echo: echo:
echo Install [%winos% ^| SKU:%osSKU% ^| %winbuild%] %_chan% echo Install [%winos% ^| SKU:%osSKU% ^| %winbuild%] %channel% Key
echo [%key%] echo [%key%]
%line% %line%
echo: echo:
if not "%regSKU%"=="%wmiSKU%" ( if not "%regSKU%"=="%wmiSKU%" (
echo Note: Difference Found In SKU Value- WMI:%wmiSKU% Reg:%regSKU% echo Note: Difference Found In SKU Value- WMI:%wmiSKU% Reg:%regSKU%
echo Restart the system to resolve it
echo: echo:
) )
call :dk_color %_Green% "Press [1] to Continue or [2] to Exit" call :dk_color %_Green% "Press [1] to Continue or [0] to %_exitmsg%"
choice /C:21 /N choice /C:01 /N
if %errorlevel%==1 exit /b if %errorlevel%==1 exit /b
cls
::======================================================================================================================================== ::========================================================================================================================================
@ -270,20 +261,18 @@ set error_code=%errorlevel%
cmd /c exit /b %error_code% cmd /c exit /b %error_code%
if %error_code% NEQ 0 set "error_code=[0x%=ExitCode%]" if %error_code% NEQ 0 set "error_code=[0x%=ExitCode%]"
echo:
echo [%winos% ^| SKU:%osSKU% ^| %winbuild%]
echo Installing %channel% [%key%]
echo:
if %error_code% EQU 0 ( if %error_code% EQU 0 (
call :dk_refresh call :dk_refresh
echo:
echo [%winos% ^| SKU:%osSKU% ^| %winbuild%]
echo Installing %_chan% [%key%]
echo:
call :dk_color %Green% "[Successful]" call :dk_color %Green% "[Successful]"
) else ( ) else (
%eline%
echo [%winos% ^| SKU:%osSKU% ^| %winbuild%]
echo Installing %_chan% [%key%]
echo:
call :dk_color %Red% "[Unsuccessful] %error_code%" call :dk_color %Red% "[Unsuccessful] %error_code%"
if not defined applist echo Not Respoding: %e_wmispp% if defined actidnotfound call :dk_color %Red% "Activation ID not found for this key."
echo Check this page for help https://massgrave.dev/troubleshoot
) )
%line% %line%
@ -293,7 +282,7 @@ if not defined applist echo Not Respoding: %e_wmispp%
echo: echo:
if %_unattended%==1 timeout /t 2 & exit /b if %_unattended%==1 timeout /t 2 & exit /b
call :dk_color %_Yellow% "Press any key to exit..." call :dk_color %_Yellow% "Press any key to %_exitmsg%..."
pause >nul pause >nul
exit /b exit /b
@ -317,22 +306,6 @@ if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISE
%chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a")) %chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a"))
exit /b exit /b
:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
:dk_product
set winos=
set d1=[DllImport(\"winbrand\",CharSet=CharSet.Unicode)]public static extern string BrandingFormatString(string s);
set d2=$AP=Add-Type -Member '%d1%' -Name D1 -PassThru; $AP::BrandingFormatString('%%WINDOWS_LONG%%')
for /f "delims=" %%s in ('"%psc% %d2%"') do if not errorlevel 1 (set winos=%%s)
echo "%winos%" | find /i "Windows" 1>nul || (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName 2^>nul') do set "winos=%%b"
if %winbuild% GEQ 22000 (
set winos=!winos:Windows 10=Windows 11!
)
)
exit /b
:: Check wmic.exe :: Check wmic.exe
:dk_ckeckwmic :dk_ckeckwmic
@ -343,91 +316,32 @@ wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "com
) )
exit /b exit /b
:dk_initial :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
echo: :dk_product
echo Initializing...
:: Check and enable WinMgmt, sppsvc services if required call :dk_reflection
for %%# in (WinMgmt sppsvc) do ( set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
for /f "skip=2 tokens=2*" %%a in ('reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v Start 2^>nul') do if /i %%b NEQ 0x2 ( set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%')
echo:
echo Enabling %%# service... set winos=
if /i %%#==sppsvc sc config %%# start= delayed-auto %nul% || echo Failed for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s)
if /i %%#==WinMgmt sc config %%# start= auto %nul% || echo Failed echo "%winos%" | find /i "Windows" 1>nul || (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName 2^>nul') do set "winos=%%b"
if %winbuild% GEQ 22000 (
set winos=!winos:Windows 10=Windows 11!
) )
sc start %%# %nul%
if !errorlevel! NEQ 1056 if !errorlevel! NEQ 0 (
echo:
echo Starting %%# service...
sc start %%#
echo:
call :dk_color %Red% "Failed to start [%%#] service, rest of the process may take a long time..."
)
)
:: Check WMI and SPP Errors
call :dk_ckeckwmic
set e_wmi=
set e_wmispp=
call :dk_actids
if not defined applist (
net stop sppsvc /y %nul%
cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul%
if !errorlevel! NEQ 0 cscript //nologo %windir%\system32\slmgr.vbs /rilc %nul%
call :dk_refresh
if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "computersystem" 1>nul
if %_wmic% EQU 0 %psc% "Get-CIMInstance -Class Win32_ComputerSystem | Select-Object -Property CreationClassName" 2>nul | find /i "computersystem" 1>nul
if !errorlevel! NEQ 0 set e_wmi=1
if defined e_wmi (set e_wmispp=WMI, SPP) else (set e_wmispp=SPP)
call :dk_actids
) )
exit /b exit /b
::======================================================================================================================================== :: Common lines used in PowerShell reflection code
:: Get Product Key from pkeyhelper.dll for future new editions :dk_reflection
:: It works on Windows 10 1803 (17134) and later builds. (Partially on 1803 & 1809, fully on 1903 and later)
:dk_pkey set ref=$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1);
set ref=%ref% $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False);
set pkey= set ref=%ref% $TypeBuilder = $ModuleBuilder.DefineType(0);
set d1=[DllImport(\"pkeyhelper.dll\",CharSet=CharSet.Unicode)]public static extern int SkuGetProductKeyForEdition(int e, string c, out string k, out string p);
set d2=$AP=Add-Type -Member '%d1%' -Name D1 -PassThru; $k=''; $null=$AP::SkuGetProductKeyForEdition(%1, %2, [ref]$k, [ref]$null); $k
for /f %%a in ('%psc% "%d2%"') do if not errorlevel 1 (set pkey=%%a)
exit /b
:: Get channel name for the key which was extracted from pkeyhelper.dll
:dk_pkeychannel
set k=%1
set pkeychannel=
set p=%SystemRoot%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms
set m=[System.Runtime.InteropServices.Marshal]
set d1=[DllImport(\"PidGenX.dll\",CharSet=CharSet.Unicode)]public static extern int PidGenX(string k,string p,string m,int u,IntPtr i,IntPtr d,IntPtr f);
set d2=$AP=Add-Type -Member '%d1%' -Name D1 -PassThru; $k='%k%'; $p='%p%'; $r=[byte[]]::new(0x04F8); $r[0]=0xF8; $r[1]=0x04; $f=%m%::AllocHGlobal(1272); %m%::Copy($r,0,$f,1272);
set d3=%d2% [void]$AP::PidGenX($k,$p,\"00000\",0,0,0,$f); %m%::Copy($f,$r,0,1272); %m%::FreeHGlobal($f); [System.Text.Encoding]::Unicode.GetString($r, 1016, 128).Replace('0','')
for /f %%a in ('%psc% "%d3%"') do if not errorlevel 1 (set pkeychannel=%%a)
exit /b
:dk_hwidkey
for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b
for %%# in (Retail OEM:NONSLP OEM:DM Volume:MAK) do (
call :dk_pkey %osSKU% '%%#'
if defined pkey call :dk_pkeychannel !pkey!
if /i [!pkeychannel!]==[%%#] (
set key=!pkey!
exit /b
)
)
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -446,76 +360,78 @@ exit /b
:: 1st column = Activation ID :: 1st column = Activation ID
:: 2nd column = Generic Retail/OEM/MAK Key :: 2nd column = Generic Retail/OEM/MAK Key
:: 3rd column = SKU ID :: 3rd column = SKU ID
:: 4th column = 1 = activation is not working (at the time of writing this), 0 = activation is working :: 4th column = Key Type
:: 5th column = Key Type :: 5th column = WMI Edition ID
:: 6th column = WMI Edition ID :: 6th column = Version name incase same Edition ID is used in different OS versions with different key
:: 7th column = Version name incase same Edition ID is used in different OS versions with different key
:: Separator = _ :: Separator = _
:: Key preference is in the following order. Retail > OEM:NONSLP > OEM:DM > Volume:MAK
:hwidkey
:hwiddata set f=
for %%# in ( for %%# in (
8b351c9c-f398-4515-9900-09df49427262_XGVPP-NMH47-7TTHJ-W3FW7-8HV2C___4_0_OEM:NONSLP_Enterprise 8b351c9c-f398-4515-9900-09df49427262_XGV%f%PP-NM%f%H47-7TTH%f%J-W3F%f%W7-8HV%f%2C___4_OEM:NONSLP_Enterprise
23505d51-32d6-41f0-8ca7-e78ad0f16e71_D6RD9-D4N8T-RT9QX-YW6YT-FCWWJ__11_1_____Retail_Starter c83cef07-6b72-4bbc-a28f-a00386872839_3V6%f%Q6-NQ%f%XCX-V8YX%f%R-9QC%f%YV-QPF%f%CT__27_Volume:MAK_EnterpriseN
c83cef07-6b72-4bbc-a28f-a00386872839_3V6Q6-NQXCX-V8YXR-9QCYV-QPFCT__27_0_Volume:MAK_EnterpriseN 4de7cb65-cdf1-4de9-8ae8-e3cce27b9f2c_VK7%f%JG-NP%f%HTM-C97J%f%M-9MP%f%GT-3V6%f%6T__48_____Retail_Professional
211b80cc-7f64-482c-89e9-4ba21ff827ad_3NFXW-2T27M-2BDW6-4GHRV-68XRX__47_1_____Retail_StarterN 9fbaf5d6-4d83-4422-870d-fdda6e5858aa_2B8%f%7N-8K%f%FHP-DKV6%f%R-Y2C%f%8J-PKC%f%KT__49_____Retail_ProfessionalN
4de7cb65-cdf1-4de9-8ae8-e3cce27b9f2c_VK7JG-NPHTM-C97JM-9MPGT-3V66T__48_0_____Retail_Professional f742e4ff-909d-4fe9-aacb-3231d24a0c58_4CP%f%RK-NM%f%3K3-X6XX%f%Q-RXX%f%86-WXC%f%HW__98_____Retail_CoreN
9fbaf5d6-4d83-4422-870d-fdda6e5858aa_2B87N-8KFHP-DKV6R-Y2C8J-PKCKT__49_0_____Retail_ProfessionalN 1d1bac85-7365-4fea-949a-96978ec91ae0_N24%f%34-X9%f%D7W-8PF6%f%X-8DV%f%9T-8TY%f%MD__99_____Retail_CoreCountrySpecific
f742e4ff-909d-4fe9-aacb-3231d24a0c58_4CPRK-NM3K3-X6XXQ-RXX86-WXCHW__98_0_____Retail_CoreN 3ae2cc14-ab2d-41f4-972f-5e20142771dc_BT7%f%9Q-G7%f%N6G-PGBY%f%W-4YW%f%X6-6F4%f%BT_100_____Retail_CoreSingleLanguage
1d1bac85-7365-4fea-949a-96978ec91ae0_N2434-X9D7W-8PF6X-8DV9T-8TYMD__99_0_____Retail_CoreCountrySpecific 2b1f36bb-c1cd-4306-bf5c-a0367c2d97d8_YTM%f%G3-N6%f%DKC-DKB7%f%7-7M9%f%GH-8HV%f%X7_101_____Retail_Core
3ae2cc14-ab2d-41f4-972f-5e20142771dc_BT79Q-G7N6G-PGBYW-4YWX6-6F4BT_100_0_____Retail_CoreSingleLanguage 2a6137f3-75c0-4f26-8e3e-d83d802865a4_XKC%f%NC-J2%f%6Q9-KFHD%f%2-FKT%f%HY-KD7%f%2Y_119_OEM:NONSLP_PPIPro
2b1f36bb-c1cd-4306-bf5c-a0367c2d97d8_YTMG3-N6DKC-DKB77-7M9GH-8HVX7_101_0_____Retail_Core e558417a-5123-4f6f-91e7-385c1c7ca9d4_YNM%f%GQ-8R%f%YV3-4PGQ%f%3-C8X%f%TP-7CF%f%BY_121_____Retail_Education
2a6137f3-75c0-4f26-8e3e-d83d802865a4_XKCNC-J26Q9-KFHD2-FKTHY-KD72Y_119_0_OEM:NONSLP_PPIPro c5198a66-e435-4432-89cf-ec777c9d0352_84N%f%GF-MH%f%BT6-FXBX%f%8-QWJ%f%K7-DRR%f%8H_122_____Retail_EducationN
e558417a-5123-4f6f-91e7-385c1c7ca9d4_YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY_121_0_____Retail_Education cce9d2de-98ee-4ce2-8113-222620c64a27_KCN%f%VH-YK%f%WX8-GJJB%f%9-H9F%f%DT-6F7%f%W2_125_Volume:MAK_EnterpriseS_VB
c5198a66-e435-4432-89cf-ec777c9d0352_84NGF-MHBT6-FXBX8-QWJK7-DRR8H_122_0_____Retail_EducationN d06934ee-5448-4fd1-964a-cd077618aa06_43T%f%BQ-NH%f%92J-XKTM%f%7-KT3%f%KK-P39%f%PB_125_OEM:NONSLP_EnterpriseS_RS5
cce9d2de-98ee-4ce2-8113-222620c64a27_KCNVH-YKWX8-GJJB9-H9FDT-6F7W2_125_1_Volume:MAK_EnterpriseS_2021 706e0cfd-23f4-43bb-a9af-1a492b9f1302_NK9%f%6Y-D9%f%CD8-W44C%f%Q-R8Y%f%TK-DYJ%f%WX_125_OEM:NONSLP_EnterpriseS_RS1
d06934ee-5448-4fd1-964a-cd077618aa06_43TBQ-NH92J-XKTM7-KT3KK-P39PB_125_0_OEM:NONSLP_EnterpriseS_2019 faa57748-75c8-40a2-b851-71ce92aa8b45_FWN%f%7H-PF%f%93Q-4GGP%f%8-M8R%f%F3-MDW%f%WW_125_OEM:NONSLP_EnterpriseS_TH
706e0cfd-23f4-43bb-a9af-1a492b9f1302_NK96Y-D9CD8-W44CQ-R8YTK-DYJWX_125_0_OEM:NONSLP_EnterpriseS_2016 2c060131-0e43-4e01-adc1-cf5ad1100da8_RQF%f%NW-9T%f%PM3-JQ73%f%T-QV4%f%VQ-DV9%f%PT_126_Volume:MAK_EnterpriseSN_VB
faa57748-75c8-40a2-b851-71ce92aa8b45_FWN7H-PF93Q-4GGP8-M8RF3-MDWWW_125_0_OEM:NONSLP_EnterpriseS_2015 e8f74caa-03fb-4839-8bcc-2e442b317e53_M33%f%WV-NH%f%Y3C-R7FP%f%M-BQG%f%PT-239%f%PG_126_Volume:MAK_EnterpriseSN_RS5
2c060131-0e43-4e01-adc1-cf5ad1100da8_RQFNW-9TPM3-JQ73T-QV4VQ-DV9PT_126_1_Volume:MAK_EnterpriseSN_2021 3d1022d8-969f-4222-b54b-327f5a5af4c9_2DB%f%W3-N2%f%PJG-MVHW%f%3-G7T%f%DK-9HK%f%R4_126_Volume:MAK_EnterpriseSN_RS1
e8f74caa-03fb-4839-8bcc-2e442b317e53_M33WV-NHY3C-R7FPM-BQGPT-239PG_126_1_Volume:MAK_EnterpriseSN_2019 60c243e1-f90b-4a1b-ba89-387294948fb6_NTX%f%6B-BR%f%YC2-K678%f%6-F6M%f%VQ-M7V%f%2X_126_Volume:MAK_EnterpriseSN_TH
3d1022d8-969f-4222-b54b-327f5a5af4c9_2DBW3-N2PJG-MVHW3-G7TDK-9HKR4_126_0_Volume:MAK_EnterpriseSN_2016 eb6d346f-1c60-4643-b960-40ec31596c45_DXG%f%7C-N3%f%6C4-C4HT%f%G-X4T%f%3X-2YV%f%77_161_____Retail_ProfessionalWorkstation
60c243e1-f90b-4a1b-ba89-387294948fb6_NTX6B-BRYC2-K6786-F6MVQ-M7V2X_126_0_Volume:MAK_EnterpriseSN_2015 89e87510-ba92-45f6-8329-3afa905e3e83_WYP%f%NQ-8C%f%467-V2W6%f%J-TX4%f%WX-WT2%f%RQ_162_____Retail_ProfessionalWorkstationN
a48938aa-62fa-4966-9d44-9f04da3f72f2_G3KNM-CHG6T-R36X3-9QDG6-8M8K9_138_1_____Retail_ProfessionalSingleLanguage 62f0c100-9c53-4e02-b886-a3528ddfe7f6_8PT%f%T6-RN%f%W4C-6V7J%f%2-C2D%f%3X-MHB%f%PB_164_____Retail_ProfessionalEducation
f7af7d09-40e4-419c-a49b-eae366689ebd_HNGCC-Y38KG-QVK8D-WMWRK-X86VK_139_1_____Retail_ProfessionalCountrySpecific 13a38698-4a49-4b9e-8e83-98fe51110953_GJT%f%YN-HD%f%MQY-FRR7%f%6-HVG%f%C7-QPF%f%8P_165_____Retail_ProfessionalEducationN
eb6d346f-1c60-4643-b960-40ec31596c45_DXG7C-N36C4-C4HTG-X4T3X-2YV77_161_0_____Retail_ProfessionalWorkstation df96023b-dcd9-4be2-afa0-c6c871159ebe_NJC%f%F7-PW%f%8QT-3324%f%D-688%f%JX-2YV%f%66_175_____Retail_ServerRdsh
89e87510-ba92-45f6-8329-3afa905e3e83_WYPNQ-8C467-V2W6J-TX4WX-WT2RQ_162_0_____Retail_ProfessionalWorkstationN d4ef7282-3d2c-4cf0-9976-8854e64a8d1e_V3W%f%VW-N2%f%PV2-CGWC%f%3-34Q%f%GF-VMJ%f%2C_178_____Retail_Cloud
62f0c100-9c53-4e02-b886-a3528ddfe7f6_8PTT6-RNW4C-6V7J2-C2D3X-MHBPB_164_0_____Retail_ProfessionalEducation af5c9381-9240-417d-8d35-eb40cd03e484_NH9%f%J3-68%f%WK7-6FB9%f%3-4K3%f%DF-DJ4%f%F6_179_____Retail_CloudN
13a38698-4a49-4b9e-8e83-98fe51110953_GJTYN-HDMQY-FRR76-HVGC7-QPF8P_165_0_____Retail_ProfessionalEducationN 8ab9bdd1-1f67-4997-82d9-8878520837d9_XQQ%f%YW-NF%f%FMW-XJPB%f%H-K87%f%32-CKF%f%FD_188_____OEM:DM_IoTEnterprise
1ca0bfa8-d96b-4815-a732-7756f30c29e2_FV469-WGNG4-YQP66-2B2HY-KD8YX_171_1_OEM:NONSLP_EnterpriseG ed655016-a9e8-4434-95d9-4345352c2552_QPM%f%6N-7J%f%2WJ-P88H%f%H-P3Y%f%RH-YY7%f%4H_191_OEM:NONSLP_IoTEnterpriseS_VB
8d6f6ffe-0c30-40ec-9db2-aad7b23bb6e3_FW7NV-4T673-HF4VX-9X4MM-B4H4T_172_1_OEM:NONSLP_EnterpriseGN d4bdc678-0a4b-4a32-a5b3-aaa24c3b0f24_K9V%f%KN-3B%f%GWV-Y624%f%W-MCR%f%MQ-BHD%f%CD_202_____Retail_CloudEditionN
df96023b-dcd9-4be2-afa0-c6c871159ebe_NJCF7-PW8QT-3324D-688JX-2YV66_175_0_____Retail_ServerRdsh 92fb8726-92a8-4ffc-94ce-f82e07444653_KY7%f%PN-VR%f%6RX-83W6%f%Y-6DD%f%YQ-T6R%f%4W_203_____Retail_CloudEdition
d4ef7282-3d2c-4cf0-9976-8854e64a8d1e_V3WVW-N2PV2-CGWC3-34QGF-VMJ2C_178_0_____Retail_Cloud d4f9b41f-205c-405e-8e08-3d16e88e02be_J7N%f%JW-V6%f%KBM-CC8R%f%W-Y29%f%Y4-HQ2%f%MJ_205_OEM:NONSLP_IoTEnterpriseSK
af5c9381-9240-417d-8d35-eb40cd03e484_NH9J3-68WK7-6FB93-4K3DF-DJ4F6_179_0_____Retail_CloudN
c7051f63-3a76-4992-bce5-731ec0b1e825_2HN6V-HGTM8-6C97C-RK67V-JQPFD_183_1_____Retail_CloudE
8ab9bdd1-1f67-4997-82d9-8878520837d9_XQQYW-NFFMW-XJPBH-K8732-CKFFD_188_0_____OEM:DM_IoTEnterprise
ed655016-a9e8-4434-95d9-4345352c2552_QPM6N-7J2WJ-P88HH-P3YRH-YY74H_191_0_OEM:NONSLP_IoTEnterpriseS
d4bdc678-0a4b-4a32-a5b3-aaa24c3b0f24_K9VKN-3BGWV-Y624W-MCRMQ-BHDCD_202_0_____Retail_CloudEditionN
92fb8726-92a8-4ffc-94ce-f82e07444653_KY7PN-VR6RX-83W6Y-6DDYQ-T6R4W_203_0_____Retail_CloudEdition
) do ( ) do (
for /f "tokens=1-8 delims=_" %%A in ("%%#") do if %osSKU%==%%C ( for /f "tokens=1-6 delims=_" %%A in ("%%#") do (
if %1==attempt1 if not defined key ( if %1==key if %osSKU%==%%C (
REM Detect key attempt 1
if "%2"=="attempt1" if not defined key (
echo "!applist!" | find /i "%%A" 1>nul && ( echo "!applist!" | find /i "%%A" 1>nul && (
set key=%%B set key=%%B
set channel=%%D
) )
) )
if %1==attempt2 if not defined key ( REM Detect key attempt 2
set 7th=%%G
if not defined 7th ( if "%2"=="attempt2" if not defined key (
if %winbuild% GTR 19044 call :dk_hwidkey %nul% set actidnotfound=1
if not defined key set key=%%B set 6th=%%F
if not defined 6th (
set key=%%B
set channel=%%D
) else ( ) else (
echo "%winos%" | find /i "%%G" 1>nul && ( echo "%branch%" | find /i "%%F" 1>nul && (
if %winbuild% GTR 19044 call :dk_hwidkey %nul% set key=%%B
if not defined key set key=%%B set channel=%%D
) )
) )
) )
)
) )
) )
exit /b exit /b

View File

@ -1,15 +0,0 @@
====================================================================================================
File Details:
====================================================================================================
cleanosppx64.exe SHA-1: d30a0e4e5911d3ca705617d17225372731c770e2
cleanosppx86.exe SHA-1: 39ed8659e7ca16aaccb86def94ce6cec4c847dd6
- These files are used in cleaning office license in C2R Retail office to VL conversion process.
- These files are taken from the old version of Microsoft official tool 'O15CTRRemove.diagcab'.
File: O15CTRRemove.diagcab (Digitally Signed)
Link: app.box.com/s/n8qpb5ljmv6djp77w5p6fk043dm6s3r1 (Unofficial Link)
SHA-1: 56c6ca76993a96cf9a255463b90db96cb9d24464
====================================================================================================

View File

@ -53,10 +53,9 @@ pushd "%~dp0"
>nul findstr /rxc:".*" "%~nx0" >nul findstr /rxc:".*" "%~nx0"
if not %errorlevel%==0 ( if not %errorlevel%==0 (
echo: echo:
echo Error: This is not a correct file. It has LF line ending issue. echo Error: Script either has LF line ending issue, or it failed to read itself.
echo: echo:
echo Press any key to exit... ping 127.0.0.1 -n 6 > nul
pause >nul
popd popd
exit /b exit /b
) )
@ -66,7 +65,7 @@ popd
cls cls
color 07 color 07
title Activation Troubleshoot title Troubleshoot
set _elev= set _elev=
if /i "%~1"=="-el" set _elev=1 if /i "%~1"=="-el" set _elev=1
@ -86,6 +85,7 @@ set cbs_log=%SystemRoot%\logs\cbs\cbs.log
set "nceline=echo: &echo ==== ERROR ==== &echo:" set "nceline=echo: &echo ==== ERROR ==== &echo:"
set "eline=echo: &call :_color %Red% "==== ERROR ====" &echo:" set "eline=echo: &call :_color %Red% "==== ERROR ====" &echo:"
set "line=_________________________________________________________________________________________________" set "line=_________________________________________________________________________________________________"
if %~z0 GEQ 200000 (set "_exitmsg=Go back") else (set "_exitmsg=Exit")
::======================================================================================================================================== ::========================================================================================================================================
@ -135,7 +135,7 @@ goto at_done
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul% reg query HKU\S-1-5-19 || ( >nul fltmc || (
if not defined _elev %nul% %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b if not defined _elev %nul% %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b
%nceline% %nceline%
echo This script require administrator privileges. echo This script require administrator privileges.
@ -167,7 +167,7 @@ setlocal EnableDelayedExpansion
cls cls
color 07 color 07
title Activation Troubleshoot title Troubleshoot
mode con cols=77 lines=30 mode con cols=77 lines=30
echo: echo:
@ -176,18 +176,18 @@ echo:
echo: echo:
echo: _______________________________________________________________ echo: _______________________________________________________________
echo: echo:
echo: [1] ReadMe call :_color2 %_White% " [1] " %_Green% "Help"
echo: ___________________________________________________ echo: ___________________________________________________
echo: echo:
echo: [2] Dism RestoreHealth echo: [2] Dism RestoreHealth
echo: [3] SFC Scannow echo: [3] SFC Scannow
echo: echo:
echo: [4] Rebuild Licensing Tokens echo: [4] Fix WMI
echo: [5] Clear Office vNext License echo: [5] Fix Licensing
echo: [6] Fix WPA Registry
echo: ___________________________________________________ echo: ___________________________________________________
echo: echo:
echo: [6] Solution: Office is not genuine banner echo: [0] %_exitmsg%
echo: [0] Exit
echo: _______________________________________________________________ echo: _______________________________________________________________
echo: echo:
call :_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard :" call :_color2 %_White% " " %_Green% "Enter a menu option in the Keyboard :"
@ -195,9 +195,9 @@ choice /C:1234560 /N
set _erl=%errorlevel% set _erl=%errorlevel%
if %_erl%==7 exit /b if %_erl%==7 exit /b
if %_erl%==6 start https://massgrave.dev/office-license-is-not-genuine &goto at_menu if %_erl%==6 start https://massgrave.dev/fix-wpa-registry.html &goto at_menu
if %_erl%==5 goto:clearvnext if %_erl%==5 goto:retokens
if %_erl%==4 goto:retokens if %_erl%==4 goto:fixwmi
if %_erl%==3 goto:sfcscan if %_erl%==3 goto:sfcscan
if %_erl%==2 goto:dism_rest if %_erl%==2 goto:dism_rest
if %_erl%==1 start https://massgrave.dev/troubleshoot.html &goto at_menu if %_erl%==1 start https://massgrave.dev/troubleshoot.html &goto at_menu
@ -209,7 +209,7 @@ goto :at_menu
cls cls
mode 98, 30 mode 98, 30
title Dism /Online /Cleanup-Image /RestoreHealth title Dism /English /Online /Cleanup-Image /RestoreHealth
if %winbuild% LSS 9200 ( if %winbuild% LSS 9200 (
%eline% %eline%
@ -219,8 +219,9 @@ goto :at_back
) )
set _int= set _int=
for %%a in (dns.msftncsi.com) do ( for %%a in (l.root-servers.net resolver1.opendns.com download.windowsupdate.com google.com) do if not defined _int (
if not defined _int (for /f "delims=[] tokens=2" %%# in ('ping -n 1 %%a') do if not [%%#]==[] set _int=1)) for /f "delims=[] tokens=2" %%# in ('ping -n 1 %%a') do (if not [%%#]==[] set _int=1)
)
echo: echo:
if defined _int ( if defined _int (
@ -242,7 +243,7 @@ call :_color2 %_White% " - " %Gray% "Make sure the Windows update is properl
echo: echo:
echo %line% echo %line%
echo: echo:
choice /C:29 /N /M "> [9] Continue [2] Go back : " choice /C:09 /N /M "> [9] Continue [0] Go back : "
if %errorlevel%==1 goto at_menu if %errorlevel%==1 goto at_menu
cls cls
@ -256,15 +257,9 @@ set _time=
for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a
echo: echo:
echo Applying the command, echo Applying the command,
echo dism /online /cleanup-image /restorehealth /Logpath:"%SystemRoot%\Temp\RHealth_DISM_%_time%.txt" /loglevel:4 echo dism /english /online /cleanup-image /restorehealth
echo: echo:
dism /online /cleanup-image /restorehealth /Logpath:"%SystemRoot%\Temp\RHealth_DISM_%_time%.txt" /loglevel:4 dism /english /online /cleanup-image /restorehealth /Logpath:"%SystemRoot%\Temp\RHealth_DISM_%_time%.txt" /loglevel:4
if not exist "!desktop!\" (
echo:
call :_color %Red% "Desktop location is not detected. Failed to copy logs on the dekstop."
goto :at_back
)
if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul% if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul%
copy /y /b "%SystemRoot%\Temp\RHealth_DISM_%_time%.txt" "!desktop!\AT_Logs\RHealth_DISM_%_time%.txt" %nul% copy /y /b "%SystemRoot%\Temp\RHealth_DISM_%_time%.txt" "!desktop!\AT_Logs\RHealth_DISM_%_time%.txt" %nul%
@ -295,7 +290,7 @@ echo restarting the PC after each time to completely fix everything that it
echo: echo:
echo %line% echo %line%
echo: echo:
choice /C:29 /N /M "> [9] Continue [2] Go back : " choice /C:09 /N /M "> [9] Continue [0] Go back : "
if %errorlevel%==1 goto at_menu if %errorlevel%==1 goto at_menu
cls cls
@ -312,108 +307,22 @@ echo sfc /scannow
echo: echo:
sfc /scannow sfc /scannow
if not exist "!desktop!\" (
echo:
call :_color %Red% "Desktop location is not detected. Failed to copy logs on the dekstop."
goto :at_back
)
if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul% if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul%
copy /y /b "%cbs_log%" "!desktop!\AT_Logs\SFC_CBS_%_time%.txt" %nul% copy /y /b "%cbs_log%" "!desktop!\AT_Logs\SFC_CBS_%_time%.txt" %nul%
findstr /i /c:"[SR]" %cbs_log% | findstr /i /v /c:verify >"!desktop!\AT_Logs\SFC_Main_%_time%.txt"
echo: echo:
call :_color %Gray% "CBS and main extracted logs are copied to the AT_Logs folder on the dekstop." call :_color %Gray% "CBS log is copied to the AT_Logs folder on the dekstop."
goto :at_back goto :at_back
::======================================================================================================================================== ::========================================================================================================================================
:clearvnext
cls
mode 98, 30
title Clear Office vNext License
echo:
echo %line%
echo:
echo This options will clear Office vNext ^(subscription^) license
echo:
echo You need to use this option when,
echo - KMS option is not activating office due to existing subscription license
echo - KMS option activated Office but Office activation page is not showing activated
echo:
echo %line%
echo:
choice /C:29 /N /M "> [9] Continue [2] Go back : "
if %errorlevel%==1 goto at_menu
cls
mode con cols=115 lines=32
%nul% %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
echo:
echo %line%
echo:
call :_color %Magenta% "Clearing Office vNext License"
echo:
setlocal DisableDelayedExpansion
set "_locl=%LocalAppData%\Microsoft\Office\Licenses"
setlocal EnableDelayedExpansion
call :cleanfolder
set "_locl=%ProgramData%\Microsoft\Office\Licenses"
call :cleanfolder
echo:
for %%# in (
HKCU\Software\Microsoft\Office\16.0\Common\Licensing
HKCU\Software\Microsoft\Office\16.0\Common\Identity
) do (
reg query %%# %nul% && (
reg delete %%# /f %nul% && (
echo Deleted Registry - %%#
) || (
echo Failed to Delete - %%#
)
) || (
echo Already Clean - %%#
)
)
goto :at_back
:cleanfolder
2>nul dir /b /a "!_locl!\*" | %nul% findstr "^" && (
pushd "!_locl!\" && (
del /S /F /Q "!_locl!\*"
for /F "delims=" %%i in ('dir /b') do (
RD /S /Q "%%i" %nul%
if not exist "!_locl!\%%i\" (
echo Deleted Folder - !_locl!\%%i
) else (
echo Failed To Delete - !_locl!\%%i
)
)
popd
)
) || (
echo Already Clean - !_locl!\
)
exit /b
::========================================================================================================================================
:retokens :retokens
cls cls
mode con cols=115 lines=32 mode con cols=115 lines=32
%nul% %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}" %nul% %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
title Rebuild Licensing Tokens ^(SPP ^+ OSPP) title Fix Licensing ^(ClipSVC ^+ Office vNext ^+ SPP ^+ OSPP^)
echo: echo:
echo %line% echo %line%
@ -422,21 +331,187 @@ echo Notes:
echo: echo:
echo - It helps in troubleshooting activation issues. echo - It helps in troubleshooting activation issues.
echo: echo:
call :_color2 %_White% " - " %Magenta% "This option will," echo - This option will,
call :_color2 %_White% " " %Magenta% "- Deactivate Windows and Office, you will need to reactivate" echo - Deactivate Windows and Office, you may need to reactivate
call :_color2 %_White% " " %Magenta% "- Uninstall Office licenses and keys" echo - Clear ClipSVC, Office vNext, SPP and OSPP licenses
call :_color2 %_White% " " %Magenta% "- Clear SPP-OSPP data.dat, tokens.dat, cache.dat" echo - Fix SPP permissions of tokens folder and registries
call :_color2 %_White% " " %Magenta% "- Trigger the repair option for Office" echo - Trigger the repair option for Office.
echo: echo:
call :_color2 %_White% " - " %Red% "Apply it only when it is necessary." call :_color2 %_White% " - " %Red% "Apply it only when it is necessary."
echo: echo:
echo %line% echo %line%
echo: echo:
choice /C:29 /N /M "> [9] Continue [2] Go back : " choice /C:09 /N /M "> [9] Continue [0] Go back : "
if %errorlevel%==1 goto at_menu if %errorlevel%==1 goto at_menu
::========================================================================================================================================
:: Rebuild ClipSVC Licences
cls cls
:cleanlicensing
echo:
echo %line%
echo:
call :_color %Magenta% "Rebuilding ClipSVC Licences"
echo:
if %winbuild% LSS 10240 (
echo ClipSVC Licence rebuilding is supported only on Win 10/11 and Server equivalent.
echo Skipping...
goto :cleanvnext
)
%psc% "(([WMISEARCHER]'SELECT Name FROM SoftwareLicensingProduct WHERE LicenseStatus=1 AND GracePeriodRemaining=0 AND PartialProductKey IS NOT NULL').Get()).Name" 2>nul | findstr /i "Windows" 1>nul && (
echo Windows is permanently activated.
echo Skipping rebuilding ClipSVC licences...
goto :cleanvnext
)
echo Stopping ClipSVC service...
call :_stopservice ClipSVC
timeout /t 2 %nul%
echo:
echo Applying the command to Clean ClipSVC Licences...
echo rundll32 clipc.dll,ClipCleanUpState
rundll32 clipc.dll,ClipCleanUpState
if %winbuild% LEQ 10240 (
echo [Successful]
) else (
if exist "%ProgramData%\Microsoft\Windows\ClipSVC\tokens.dat" (
call :_color %Red% "[Failed]"
) else (
echo [Successful]
)
)
:: Below registry key (Volatile & Protected) gets created after the ClipSVC License cleanup command, and gets automatically deleted after
:: system restart. It needs to be deleted to activate the system without restart.
set "RegKey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState"
set "_ident=HKU\S-1-5-19\SOFTWARE\Microsoft\IdentityCRL"
reg query "%RegKey%" %nul% && %nul% call :regownstart
reg delete "%RegKey%" /f %nul%
echo:
echo Deleting a Volatile ^& Protected Registry Key...
echo [%RegKey%]
reg query "%RegKey%" %nul% && (
call :_color %Red% "[Failed]"
echo Restart the system, that will delete this registry key automatically.
) || (
echo [Successful]
)
:: Clear HWID token related registry to fix activation incase if there is any corruption
echo:
echo Deleting a IdentityCRL Registry Key...
echo [%_ident%]
reg delete "%_ident%" /f %nul%
reg query "%_ident%" %nul% && (
call :_color %Red% "[Failed]"
) || (
echo [Successful]
)
call :_stopservice ClipSVC
:: Rebuild ClipSVC folder to fix permission issues
echo:
if %winbuild% GTR 10240 (
echo Deleting Folder %ProgramData%\Microsoft\Windows\ClipSVC\
rmdir /s /q "C:\ProgramData\Microsoft\Windows\ClipSvc" %nul%
if exist "%ProgramData%\Microsoft\Windows\ClipSVC\" (
call :_color %Red% "[Failed]"
) else (
echo [Successful]
)
echo:
echo Rebuilding Folder %ProgramData%\Microsoft\Windows\ClipSVC\
net start ClipSVC /y %nul%
timeout /t 3 %nul%
if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" timeout /t 5 %nul%
if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" (
call :_color %Red% "[Failed]"
) else (
echo [Successful]
)
)
echo:
echo Restarting [wlidsvc LicenseManager] services...
for %%# in (wlidsvc LicenseManager) do (net stop %%# /y %nul% & net start %%# /y %nul%)
::========================================================================================================================================
:: Clear Office vNext License
:cleanvnext
echo:
echo %line%
echo:
call :_color %Magenta% "Clearing Office vNext License"
echo:
setlocal DisableDelayedExpansion
set "_Local=%LocalAppData%"
setlocal EnableDelayedExpansion
attrib -R "!ProgramData!\Microsoft\Office\Licenses" %nul%
attrib -R "!_Local!\Microsoft\Office\Licenses" %nul%
if exist "!ProgramData!\Microsoft\Office\Licenses\" (
rd /s /q "!ProgramData!\Microsoft\Office\Licenses\" %nul%
if exist "!ProgramData!\Microsoft\Office\Licenses\" (
echo Failed To Delete - !ProgramData!\Microsoft\Office\Licenses\
) else (
echo Deleted Folder - !ProgramData!\Microsoft\Office\Licenses\
)
) else (
echo Not Found - !ProgramData!\Microsoft\Office\Licenses\
)
if exist "!_Local!\Microsoft\Office\Licenses\" (
rd /s /q "!_Local!\Microsoft\Office\Licenses\" %nul%
if exist "!_Local!\Microsoft\Office\Licenses\" (
echo Failed To Delete - !_Local!\Microsoft\Office\Licenses\
) else (
echo Deleted Folder - !_Local!\Microsoft\Office\Licenses\
)
) else (
echo Not Found - !_Local!\Microsoft\Office\Licenses\
)
echo:
for %%# in (
HKCU\Software\Microsoft\Office\16.0\Common\Licensing
HKCU\Software\Microsoft\Office\16.0\Registration
) do (
reg query %%# %nul% && (
reg delete %%# /f %nul% && (
echo Deleted Registry - %%#
) || (
echo Failed to Delete - %%#
)
) || (
echo Not Found Registry - %%#
)
)
::========================================================================================================================================
:: Rebuild SPP Tokens
echo: echo:
echo %line% echo %line%
echo: echo:
@ -451,6 +526,64 @@ call :_color %Red% "tokens.dat file not found."
echo tokens.dat file: [%token%] echo tokens.dat file: [%token%]
) )
if %winbuild% GEQ 14393 (
set wpaerror=
set /a count=0
for /f %%a in ('reg query "HKLM\SYSTEM\WPA" 2^>nul') do set /a count+=1
for /L %%# in (1,1,!count!) do (
reg query "HKLM\SYSTEM\WPA\8DEC0AF1-0341-4b93-85CD-72606C2DF94C-7P-%%#" /ve /t REG_BINARY %nul% || set wpaerror=1
)
if defined wpaerror (
echo:
echo Checking WPA Registry Keys...
call :_color %Red% "[Error Found] [Registry Count - !count!]"
)
)
set tokenstore=
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore 2^>nul') do call set "tokenstore=%%b"
:: Check sppsvc permissions and apply fixes
if %winbuild% GEQ 10240 (
echo:
echo Checking SPP permission related issues...
call :checkperms
if defined permerror (
mkdir "%tokenstore%" %nul%
set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';"
set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;"
set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);"
set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;"
%psc% "!d!" %nul%
for %%# in (
"HKLM:\SYSTEM\WPA_QueryValues, EnumerateSubKeys, WriteKey"
"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform_SetValue"
) do for /f "tokens=1,2 delims=_" %%A in (%%#) do (
set "d=$acl = Get-Acl '%%A';"
set "d=!d! $rule = New-Object System.Security.AccessControl.RegistryAccessRule ('NT Service\sppsvc', '%%B', 'ContainerInherit, ObjectInherit','None','Allow');"
set "d=!d! $acl.ResetAccessRule($rule);"
set "d=!d! $acl.SetAccessRule($rule);"
set "d=!d! Set-Acl -Path '%%A' -AclObject $acl"
%psc% "!d!" %nul%
)
call :checkperms
if defined permerror (
call :_color %Red% "[Failed To Fix]"
) else (
echo [Successfully Fixed]
)
) else (
echo [Error Not Found]
)
)
echo: echo:
echo Stopping sppsvc service... echo Stopping sppsvc service...
call :_stopservice sppsvc call :_stopservice sppsvc
@ -481,7 +614,7 @@ echo:
if not defined token ( if not defined token (
call :_color %Red% "Failed to rebuilt tokens.dat file." call :_color %Red% "Failed to rebuilt tokens.dat file."
) else ( ) else (
call :_color %Green% "tokens.dat file was rebuilt successfully." echo tokens.dat file was rebuilt successfully.
) )
::======================================================================================================================================== ::========================================================================================================================================
@ -491,17 +624,15 @@ call :_color %Green% "tokens.dat file was rebuilt successfully."
echo: echo:
echo %line% echo %line%
echo: echo:
sc qc osppsvc %nul% || (
echo:
call :_color %Magenta% "OSPP based Office is not installed"
call :_color %Magenta% "Skipping rebuilding OSPP tokens"
goto :cleanclipsvc
)
call :_color %Magenta% "Rebuilding OSPP Licensing Tokens" call :_color %Magenta% "Rebuilding OSPP Licensing Tokens"
echo: echo:
sc qc osppsvc %nul% || (
echo OSPP based Office is not installed
echo Skipping rebuilding OSPP tokens...
goto :repairoffice
)
call :scandatospp check call :scandatospp check
if not defined token ( if not defined token (
@ -540,17 +671,11 @@ echo:
if not defined token ( if not defined token (
call :_color %Red% "Failed to rebuilt tokens.dat file." call :_color %Red% "Failed to rebuilt tokens.dat file."
) else ( ) else (
call :_color %Green% "tokens.dat file was rebuilt successfully." echo tokens.dat file was rebuilt successfully.
) )
::======================================================================================================================================== ::========================================================================================================================================
:cleanclipsvc
:: This section is removed
::========================================================================================================================================
:repairoffice :repairoffice
echo: echo:
@ -597,10 +722,11 @@ set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office
%nul% reg query %_86%\ClickToRun /v InstallPath && (set "c2r16_86=Office 16.0 C2R x86" & set "c2r16repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe") %nul% reg query %_86%\ClickToRun /v InstallPath && (set "c2r16_86=Office 16.0 C2R x86" & set "c2r16repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe")
set uwp16= set uwp16=
if %winbuild% GEQ 10240 reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msoxmled.exe" %nul% && ( if %winbuild% GEQ 10240 (
dir /b "%ProgramFiles%\WindowsApps\Microsoft.Office.Desktop*" %nul% && set uwp16=Office 16.0 UWP dir /b "%ProgramFiles%\WindowsApps\Microsoft.Office.Desktop*" %nul% && set uwp16=Office 16.0 UWP
dir /b "%ProgramW6432%\WindowsApps\Microsoft.Office.Desktop*" %nul% && set uwp16=Office 16.0 UWP dir /b "%ProgramW6432%\WindowsApps\Microsoft.Office.Desktop*" %nul% && set uwp16=Office 16.0 UWP
dir /b "%ProgramFiles(x86)%\WindowsApps\Microsoft.Office.Desktop*" %nul% && set uwp16=Office 16.0 UWP dir /b "%ProgramFiles(x86)%\WindowsApps\Microsoft.Office.Desktop*" %nul% && set uwp16=Office 16.0 UWP
%psc% "Get-AppxPackage -name "Microsoft.Office.Desktop"" | find /i "Office" 1>nul && set uwp16=Office 16.0 UWP
) )
set /a counter=0 set /a counter=0
@ -645,7 +771,7 @@ goto :repairend
echo: echo:
) else ( ) else (
echo: echo:
call :_color %_Yellow% "A Window will popup, in that Window you need to select Repair Option..." call :_color %_Yellow% "A Window will popup, in that Window you need to select [Quick] Repair Option..."
call :_color %_Yellow% "Press any key to continue..." call :_color %_Yellow% "Press any key to continue..."
echo: echo:
pause >nul pause >nul
@ -691,6 +817,147 @@ echo %line%
echo: echo:
echo: echo:
call :_color %Green% "Finished" call :_color %Green% "Finished"
goto :at_back
::========================================================================================================================================
:fixwmi
cls
mode 98, 34
title Fix WMI
:: https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-repository-corruption-or-not/ba-p/375484
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
%eline%
echo WMI rebuild is not recommended on Windows Server. Aborting...
goto :at_back
)
for %%# in (wmic.exe) do @if "%%~$PATH:#"=="" (
%eline%
echo wmic.exe file is not found in the system. Aborting...
goto :at_back
)
echo:
echo Checking WMI
set error=
wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "computersystem" 1>nul
if %errorlevel% NEQ 0 set error=1
winmgmt /verifyrepository %nul%
if %errorlevel% NEQ 0 set error=1
if not defined error (
echo [Working]
echo No need to apply this option. Aborting...
goto :at_back
)
call :_color %Red% "[Not Responding]"
echo:
sc query Winmgmt %nul% || (
%eline%
echo Winmgmt service is not installed. Aborting...
goto :at_back
)
echo Disabling Winmgmt service
sc config Winmgmt start= disabled %nul%
if %errorlevel% EQU 0 (
echo [Successful]
) else (
call :_color %Red% "[Failed] Aborting..."
sc config Winmgmt start= auto %nul%
goto :at_back
)
echo:
echo Stopping Winmgmt service
call :_stopservice Winmgmt
call :_stopservice Winmgmt
call :_stopservice Winmgmt
sc query Winmgmt | find /i "1 STOPPED" %nul% && (
echo [Successful]
) || (
call :_color %Red% "[Failed]"
echo:
call :_color %Magenta% "Its recommended to select [Restart] option and then apply Fix WMI option again."
echo %line%
echo:
choice /C:21 /N /M "> [1] Restart [2] Revert Back Changes :"
if !errorlevel!==1 (sc config Winmgmt start= auto %nul%&goto :at_back)
echo:
echo Restarting...
shutdown -t 5 -r
exit
)
echo:
echo Deleting WMI repository
rmdir /s /q "%windir%\System32\wbem\repository\" %nul%
if exist "%windir%\System32\wbem\repository\" (
call :_color %Red% "[Failed]"
) else (
echo [Successful]
)
echo:
echo Enabling Winmgmt service
sc config Winmgmt start= auto %nul%
if %errorlevel% EQU 0 (
echo [Successful]
) else (
call :_color %Red% "[Failed]"
)
wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "computersystem" 1>nul
if %errorlevel% EQU 0 (
echo:
echo Checking WMI
call :_color %Green% "[Working]"
goto :at_back
)
echo:
echo Registering .dll's and Compiling .mof's, .mfl's
call :registerobj %nul%
echo:
echo Checking WMI
wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "computersystem" 1>nul
if %errorlevel% NEQ 0 (
call :_color %Red% "[Not Responding]"
echo:
echo Run [Dism RestoreHealth] and [SFC Scannow] options and make sure there are no errors.
) else (
call :_color %Green% "[Working]"
)
goto :at_back
:registerobj
:: https://eskonr.com/2012/01/how-to-fix-wmi-issues-automatically/
call :_stopservice Winmgmt
cd /d %systemroot%\system32\wbem\
regsvr32 /s %systemroot%\system32\scecli.dll
regsvr32 /s %systemroot%\system32\userenv.dll
mofcomp cimwin32.mof
mofcomp cimwin32.mfl
mofcomp rsop.mof
mofcomp rsop.mfl
for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
for /f %%s in ('dir /b *.mof') do mofcomp %%s
for /f %%s in ('dir /b *.mfl') do mofcomp %%s
winmgmt /salvagerepository
winmgmt /resetrepository
exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -708,7 +975,7 @@ goto :at_menu
:at_done :at_done
echo: echo:
echo Press any key to exit... echo Press any key to %_exitmsg%...
pause >nul pause >nul
exit /b exit /b
@ -732,6 +999,23 @@ exit /b
::======================================================================================================================================== ::========================================================================================================================================
:checkperms
set permerror=
if not exist "%tokenstore%\" set permerror=1
for %%# in (
"%tokenstore%"
"HKLM:\SYSTEM\WPA"
"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
) do if not defined permerror (
%psc% "$acl = Get-Acl '%%#'; if ($acl.Access.Where{ $_.IdentityReference -eq 'NT SERVICE\sppsvc' -and $_.AccessControlType -eq 'Deny' -or $acl.Access.IdentityReference -notcontains 'NT SERVICE\sppsvc'}) {Exit 2}" %nul%
if !errorlevel!==2 set permerror=1
)
exit /b
::========================================================================================================================================
:scandat :scandat
set token= set token=
@ -779,7 +1063,41 @@ del /S /F /Q "%%#*.dat"
) )
exit /b exit /b
::========================================================================================================================================\ ::========================================================================================================================================
:regownstart
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regown\:.*';iex ($f[1]);"
exit /b
:: Below code takes ownership of a volatile registry key and deletes it
:: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState
:regown:
$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1)
$ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False)
$TypeBuilder = $ModuleBuilder.DefineType(0)
$TypeBuilder.DefinePInvokeMethod('RtlAdjustPrivilege', 'ntdll.dll', 'Public, Static', 1, [int], @([int], [bool], [bool], [bool].MakeByRefType()), 1, 3) | Out-Null
$TypeBuilder.CreateType()::RtlAdjustPrivilege(9, $true, $false, [ref]$false) | Out-Null
$SID = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544')
$IDN = ($SID.Translate([System.Security.Principal.NTAccount])).Value
$Admin = New-Object System.Security.Principal.NTAccount($IDN)
$path = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState'
$key = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey($path, 'ReadWriteSubTree', 'takeownership')
$acl = $key.GetAccessControl()
$acl.SetOwner($Admin)
$key.SetAccessControl($acl)
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($Admin,"FullControl","Allow")
$acl.SetAccessRule($rule)
$key.SetAccessControl($acl)
:regown:
::========================================================================================================================================
:_color :_color

View File

@ -1,23 +1,45 @@
**Microsoft Activation Scripts (MAS):** ## Microsoft Activation Scripts (MAS):
A collection of scripts for activating Microsoft products using HWID / KMS38 / Online KMS activation methods A Windows and Office activator using HWID / KMS38 / Online KMS activation methods, with a focus on open-source code and fewer antivirus detections.
with a focus on open-source code, less antivirus detection and user-friendliness.
## Download / How to use it?
**[Download Link](https://github.com/massgravel/Microsoft-Activation-Scripts/releases)** <br/> ### Method 1 - PowerShell
Latest Version: 1.6 - On Windows 10/11, right-click on the windows start menu and select PowerShell or Terminal (Not CMD).
Release date: 25-July-2022 - Copy-paste the below code and press enter\
`irm https://massgrave.dev/get | iex`
- You will see the activation options, and follow onscreen instructions.
- That's all.
**For more details, check Homepage:** https://massgrave.dev/ <br/> ### Method 2 - Traditional
- Download the file named `MAS_1.8_Password_1234.7z` from [here](https://github.com/massgravel/Microsoft-Activation-Scripts/releases)
- Extract this file with a 3rd party archive manager, such as [7zip](https://www.7-zip.org/download.html)
- Password is `1234`
- In the extracted folder, find the folder named `All-In-One-Version`
- Run the file named `MAS_AIO.cmd`
- You will see the activation options, and follow onscreen instructions.
- That's all.
To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches.html)
```
Latest Version: 1.8
Release date: 16-Mar-2023
```
### For more details, check Homepage: https://massgrave.dev/
### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media.html)
<a href="https://discord.gg/gjJEfq7ux8"> <a href="https://discord.gg/gjJEfq7ux8">
<img src="https://discordapp.com/api/guilds/746721520931569757/widget.png?style=banner3" /> <img src="https://discordapp.com/api/guilds/746721520931569757/widget.png?style=banner3" />
</a> </a>
<hr />
---
Made with Love ❤️ Made with Love ❤️