@echo off
:: first go get the skus.zip - in the issues are the ones for W11 too
echo [92m Starting conversion to[1;105m LTSC...[0m
:: If not launched as admin, relaunch
net.exe session 2>NUL 1>&2
if not %errorlevel%==0 (echo [91;44;4m You are NOT ADMIN. Relaunching... [0m
powershell Start -File "cmd '/K %~f0 runas'" -Verb RunAs
goto out)
:start
pushd "%CD%"
CD /D "%~dp0"
echo [96m Take ownership of the skus subfolders [0m
"%windir%\system32\takeown.exe" /F "%windir%\system32\spp\tokens\skus\csvlk-pack" /R /A /D Y
"%windir%\system32\icacls.exe" "%windir%\system32\spp\tokens\skus\csvlk-pack" /T /grant Administrators:F
"%windir%\system32\takeown.exe" /F "%windir%\system32\spp\tokens\skus\IoTEnterpriseS" /R /A /D Y
"%windir%\system32\icacls.exe" "%windir%\system32\spp\tokens\skus\IoTEnterpriseS" /T /grant Administrators:F
"%windir%\system32\takeown.exe" /F "%windir%\system32\spp\tokens\skus\IoTEnterpriseSK" /R /A /D Y
"%windir%\system32\icacls.exe" "%windir%\system32\spp\tokens\skus\IoTEnterpriseSK" /T /grant Administrators:F
"%windir%\system32\takeown.exe" /F "%windir%\System32\spp\tokens\EnterpriseS" /R /A /D Y
"%windir%\system32\icacls.exe" "%windir%\system32\spp\tokens\skus\EnterpriseS" /T /grant Administrators:F
echo. [0m
echo [96m Extract and copy the new skus [0m
FOR /F "tokens=1,2,3 delims= " %%A IN ('wmic os get Caption') DO @IF %%C EQU 10 "%windir%\System32\tar.exe" -v -x -f skus10.zip -C %windir%\system32\spp\tokens\skus
FOR /F "tokens=1,2,3 delims= " %%A IN ('wmic os get Caption') DO @IF %%C EQU 11 "%windir%\System32\tar.exe" -v -x -f skus11.zip -C %windir%\system32\spp\tokens\skus
echo [96m Reinstall the new licenses - be patient, this will take a minute [0m
cscript.exe %windir%\system32\slmgr.vbs /rilc
echo [96m Uninstall the actual product key [0m
cscript.exe %windir%\system32\slmgr.vbs /upk
echo [96m Remove the KMS [0m
cscript.exe %windir%\system32\slmgr.vbs /ckms
echo [96m Remove the old product key from registry [0m
cscript.exe %windir%\system32\slmgr.vbs /cpky
echo [96m Install LTSC Product key [0m
:: use key from https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys - it requires a KMS Server, otherwise you will have to manually change the license from KMS to MAK
cscript.exe %windir%\system32\slmgr.vbs /ipk M7XTQ-FN8P6-TTKYV-9D4CC-J462D
:end
:: cleanup
del /f /q "skus*.zip" 2>nul
:: check the Windows version
wmic os get Caption | findstr "Microsoft"
echo [96m Now we should reboot... [0;4;1;41m
choice /t 30 /c yn /d n /n /m "press "Y" in the next 30 seconds if you want to reboot"
if errorlevel 2 goto :out
if errorlevel 1 shutdown.exe -r -f -t 0
:out
:: reset the colors
echo.[0m