diff options
Diffstat (limited to 'MAS/Separate-Files-Version/Change_Edition.cmd')
| -rw-r--r-- | MAS/Separate-Files-Version/Change_Edition.cmd | 220 |
1 files changed, 120 insertions, 100 deletions
diff --git a/MAS/Separate-Files-Version/Change_Edition.cmd b/MAS/Separate-Files-Version/Change_Edition.cmd index 06dd798..f118126 100644 --- a/MAS/Separate-Files-Version/Change_Edition.cmd +++ b/MAS/Separate-Files-Version/Change_Edition.cmd @@ -57,7 +57,7 @@ pushd "%~dp0" >nul findstr /rxc:".*" "%~nx0"
if not %errorlevel%==0 (
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:
ping 127.0.0.1 -n 6 > nul
popd
@@ -116,15 +116,6 @@ echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equiva goto ced_done
)
-if %winbuild% LSS 9200 if not exist "%SystemRoot%\servicing\Packages\Microsoft-Windows-PowerShell-WTR-Package~*.mum" (
-%nceline%
-echo Updated Powershell not found.
-echo:
-echo Download Windows Management Framework 5.1 from below link and install
-echo https://aka.ms/wmf5download
-goto ced_done
-)
-
for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" (
%nceline%
echo Unable to find powershell.exe in the system.
@@ -202,6 +193,8 @@ 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
)
@@ -216,6 +209,8 @@ DISM /English /Online /Get-CurrentEdition %nul% cmd /c exit /b !errorlevel!
echo DISM command failed [Error Code - 0x!=ExitCode!]
echo OS Edition was not detected properly. Aborting...
+echo:
+echo Check this page for help. https://massgrave.dev/troubleshoot
goto ced_done
)
@@ -351,9 +346,9 @@ echo: %line%
echo:
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
-echo [1] DISM Method
+echo [1] DISM Method [Recommended]
) else (
-echo [1] Changepk Method
+echo [1] Changepk Method [Recommended]
)
echo:
echo [2] CBS Upgrade Method [Alternative]
@@ -387,7 +382,6 @@ cls set key=
set _chan=
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
@@ -401,11 +395,16 @@ set _changepk=1 )
)
-if %winbuild% LEQ 19045 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 if defined targetSKU call :ced_windowskey
if defined key if defined pkeychannel set _chan=%pkeychannel%
+if not defined key call :changeeditiondata
if not defined key (
%eline%
@@ -437,7 +436,7 @@ goto ced_done cls
if %_changepk%==1 (
-for %%a in (dns.msftncsi.com,www.microsoft.com,one.one.one.one,resolver1.opendns.com) do (
+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 (
if not [%%#]==[] (
%eline%
@@ -455,18 +454,15 @@ echo Changing the Current Edition [%osedition%] to [%targetedition%] echo:
if %_changepk%==1 (
-call :dk_color %_Green% "You can safely ignore if error appears in the upgrade Window."
-call :dk_color %_Yellow% "But in that case you must manually reboot the system."
+call :dk_color %Magenta% "Notes-"
echo:
-%psc% "$BLinfo = Get-BitLockerVolume -MountPoint "C:";$blinfo.ProtectionStatus" | find /i "On" 1>nul && (
-call :dk_color %Red% "Bitlocker / Device Encryption is On in the system."
+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 Either Use alternative CBS upgrade method for edition change
-echo Or Ensure that you have it's recovery key, you may need it
-echo Or Turn off Bitlocker / Device Encryption
+echo - Save your work before continue, system will auto restart.
+echo - You can connect to Internet after the system restart.
echo:
-)
-call :dk_color %Magenta% "Important - Save your work before continue, system will auto reboot."
+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
@@ -600,14 +596,27 @@ 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"))
exit /b
+:: Check wmic.exe
+
+:dk_ckeckwmic
+
+set _wmic=0
+for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
+wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "computersystem" 1>nul && set _wmic=1
+)
+exit /b
+
:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
:dk_product
+call :dk_reflection
+
+set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
+set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%')
+
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)
+for /f "delims=" %%s in ('"%psc% %d1%"') 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 (
@@ -616,14 +625,13 @@ set winos=!winos:Windows 10=Windows 11! )
exit /b
-:: Check wmic.exe
+:: Common lines used in PowerShell reflection code
-:dk_ckeckwmic
+:dk_reflection
-set _wmic=0
-for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
-wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "computersystem" 1>nul && set _wmic=1
-)
+set ref=$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1);
+set ref=%ref% $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False);
+set ref=%ref% $TypeBuilder = $ModuleBuilder.DefineType(0);
exit /b
::========================================================================================================================================
@@ -633,24 +641,30 @@ exit /b :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 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)
+for /f %%a in ('%psc% "%d1%"') 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 m=[Runtime.InteropServices.Marshal]
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)
+
+set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('PidGenX', 'pidgenx.dll', 'Public, Static', 1, [int], @([String], [String], [String], [int], [IntPtr], [IntPtr], [IntPtr]), 1, 3);
+set d1=%d1% $r = [byte[]]::new(0x04F8); $r[0] = 0xF8; $r[1] = 0x04; $f = %m%::AllocHGlobal(0x04F8); %m%::Copy($r, 0, $f, 0x04F8);
+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)
+
+set pkeychannel=
+for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkeychannel=%%a)
exit /b
:ced_windowskey
@@ -673,9 +687,13 @@ exit /b set k=%1
set targetSKU=
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
-for /f %%a in ('%psc% "%d2%"') do if not errorlevel 1 (set targetSKU=%%a)
+
+call :dk_reflection
+
+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=
exit /b
@@ -839,7 +857,7 @@ function Write-UpgradeXml { }
function Write-Usage {
- Get-Help $PSCommandPath -detailed
+ Get-Help $script:MyInvocation.MyCommand.Path -detailed
}
$version = '1.0'
@@ -854,7 +872,7 @@ if($SetEdition -eq '' -and ($false -eq $getTargetsParam)) { $removalCandidates = @();
$installCandidates = @{};
-$packages = Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages' | select Name | where name -Match '^.*\\Microsoft-Windows-.*Edition~'
+$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]
@@ -865,12 +883,12 @@ foreach($package in $packages) { $installCandidates[$packageEdition] = @()
}
- if($false -eq ($packageName -in $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 ($packageName -in $removalCandidates))) {
+ if((($state -eq 0x50) -or ($state -eq 0x70)) -and ($false -eq ($removalCandidates -contains $packageName))) {
$removalCandidates = $removalCandidates + @($packageName)
}
}
@@ -880,12 +898,12 @@ if($getTargetsParam) { Exit
}
-if($false -eq ($SetEdition -in $installCandidates.Keys)) {
+if($false -eq ($installCandidates.Keys -contains $SetEdition)) {
Write-Error "The system cannot be upgraded to `"$SetEdition`""
Exit 1
}
-$xmlPath = $Env:Temp + '\CbsUpgrade.xml'
+$xmlPath = $Env:SystemRoot + '\Temp' + '\CbsUpgrade.xml'
Write-UpgradeXml -RemovalCandidates $removalCandidates `
-InstallCandidates $installCandidates[$SetEdition] `
@@ -938,46 +956,47 @@ Restart-Computer :changeeditiondata
+set h=
for %%# in (
-44NYX-TKR9D-CCM2D-V6B8F-HQWWR__Volume:MAK_Enterprise
-D6RD9-D4N8T-RT9QX-YW6YT-FCWWJ______Retail_Starter
-3V6Q6-NQXCX-V8YXR-9QCYV-QPFCT__Volume:MAK_EnterpriseN
-3NFXW-2T27M-2BDW6-4GHRV-68XRX______Retail_StarterN
-VK7JG-NPHTM-C97JM-9MPGT-3V66T______Retail_Professional
-2B87N-8KFHP-DKV6R-Y2C8J-PKCKT______Retail_ProfessionalN
-4CPRK-NM3K3-X6XXQ-RXX86-WXCHW______Retail_CoreN
-N2434-X9D7W-8PF6X-8DV9T-8TYMD______Retail_CoreCountrySpecific
-BT79Q-G7N6G-PGBYW-4YWX6-6F4BT______Retail_CoreSingleLanguage
-YTMG3-N6DKC-DKB77-7M9GH-8HVX7______Retail_Core
-XKCNC-J26Q9-KFHD2-FKTHY-KD72Y__OEM:NONSLP_PPIPro
-YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY______Retail_Education
-84NGF-MHBT6-FXBX8-QWJK7-DRR8H______Retail_EducationN
-KCNVH-YKWX8-GJJB9-H9FDT-6F7W2__Volume:MAK_EnterpriseS_VB
-VBX36-N7DDY-M9H62-83BMJ-CPR42__Volume:MAK_EnterpriseS_RS5
-PN3KR-JXM7T-46HM4-MCQGK-7XPJQ__Volume:MAK_EnterpriseS_RS1
-DVWKN-3GCMV-Q2XF4-DDPGM-VQWWY__Volume:MAK_EnterpriseS_TH
-RQFNW-9TPM3-JQ73T-QV4VQ-DV9PT__Volume:MAK_EnterpriseSN_VB
-M33WV-NHY3C-R7FPM-BQGPT-239PG__Volume:MAK_EnterpriseSN_RS5
-2DBW3-N2PJG-MVHW3-G7TDK-9HKR4__Volume:MAK_EnterpriseSN_RS1
-NTX6B-BRYC2-K6786-F6MVQ-M7V2X__Volume:MAK_EnterpriseSN_TH
-G3KNM-CHG6T-R36X3-9QDG6-8M8K9______Retail_ProfessionalSingleLanguage
-HNGCC-Y38KG-QVK8D-WMWRK-X86VK______Retail_ProfessionalCountrySpecific
-DXG7C-N36C4-C4HTG-X4T3X-2YV77______Retail_ProfessionalWorkstation
-WYPNQ-8C467-V2W6J-TX4WX-WT2RQ______Retail_ProfessionalWorkstationN
-8PTT6-RNW4C-6V7J2-C2D3X-MHBPB______Retail_ProfessionalEducation
-GJTYN-HDMQY-FRR76-HVGC7-QPF8P______Retail_ProfessionalEducationN
-C4NTJ-CX6Q2-VXDMR-XVKGM-F9DJC__Volume:MAK_EnterpriseG
-46PN6-R9BK9-CVHKB-HWQ9V-MBJY8__Volume:MAK_EnterpriseGN
-NJCF7-PW8QT-3324D-688JX-2YV66______Retail_ServerRdsh
-V3WVW-N2PV2-CGWC3-34QGF-VMJ2C______Retail_Cloud
-NH9J3-68WK7-6FB93-4K3DF-DJ4F6______Retail_CloudN
-2HN6V-HGTM8-6C97C-RK67V-JQPFD______Retail_CloudE
-XQQYW-NFFMW-XJPBH-K8732-CKFFD______OEM:DM_IoTEnterprise
-QPM6N-7J2WJ-P88HH-P3YRH-YY74H__OEM:NONSLP_IoTEnterpriseS_VB
-KBN8V-HFGQ4-MGXVD-347P6-PDQGT_Volume:GVLK_IoTEnterpriseS_NI
-K9VKN-3BGWV-Y624W-MCRMQ-BHDCD______Retail_CloudEditionN
-KY7PN-VR6RX-83W6Y-6DDYQ-T6R4W______Retail_CloudEdition
-MPB3G-XNBR7-CC43M-FG64B-F9GBK______Retail_IoTEnterpriseSK
+44N%h%YX-TK%h%R9D-CCM2%h%D-V6%h%B8F-HQ%h%WWR__Volume:MAK_Enterprise
+D6R%h%D9-D4%h%N8T-RT9Q%h%X-YW%h%6YT-FC%h%WWJ______Retail_Starter
+3V6%h%Q6-NQ%h%XCX-V8YX%h%R-9Q%h%CYV-QP%h%FCT__Volume:MAK_EnterpriseN
+3NF%h%XW-2T%h%27M-2BDW%h%6-4G%h%HRV-68%h%XRX______Retail_StarterN
+VK7%h%JG-NP%h%HTM-C97J%h%M-9M%h%PGT-3V%h%66T______Retail_Professional
+2B8%h%7N-8K%h%FHP-DKV6%h%R-Y2%h%C8J-PK%h%CKT______Retail_ProfessionalN
+4CP%h%RK-NM%h%3K3-X6XX%h%Q-RX%h%X86-WX%h%CHW______Retail_CoreN
+N24%h%34-X9%h%D7W-8PF6%h%X-8D%h%V9T-8T%h%YMD______Retail_CoreCountrySpecific
+BT7%h%9Q-G7%h%N6G-PGBY%h%W-4Y%h%WX6-6F%h%4BT______Retail_CoreSingleLanguage
+YTM%h%G3-N6%h%DKC-DKB7%h%7-7M%h%9GH-8H%h%VX7______Retail_Core
+XKC%h%NC-J2%h%6Q9-KFHD%h%2-FK%h%THY-KD%h%72Y__OEM:NONSLP_PPIPro
+YNM%h%GQ-8R%h%YV3-4PGQ%h%3-C8%h%XTP-7C%h%FBY______Retail_Education
+84N%h%GF-MH%h%BT6-FXBX%h%8-QW%h%JK7-DR%h%R8H______Retail_EducationN
+KCN%h%VH-YK%h%WX8-GJJB%h%9-H9%h%FDT-6F%h%7W2__Volume:MAK_EnterpriseS_VB
+VBX%h%36-N7%h%DDY-M9H6%h%2-83%h%BMJ-CP%h%R42__Volume:MAK_EnterpriseS_RS5
+PN3%h%KR-JX%h%M7T-46HM%h%4-MC%h%QGK-7X%h%PJQ__Volume:MAK_EnterpriseS_RS1
+DVW%h%KN-3G%h%CMV-Q2XF%h%4-DD%h%PGM-VQ%h%WWY__Volume:MAK_EnterpriseS_TH
+RQF%h%NW-9T%h%PM3-JQ73%h%T-QV%h%4VQ-DV%h%9PT__Volume:MAK_EnterpriseSN_VB
+M33%h%WV-NH%h%Y3C-R7FP%h%M-BQ%h%GPT-23%h%9PG__Volume:MAK_EnterpriseSN_RS5
+2DB%h%W3-N2%h%PJG-MVHW%h%3-G7%h%TDK-9H%h%KR4__Volume:MAK_EnterpriseSN_RS1
+NTX%h%6B-BR%h%YC2-K678%h%6-F6%h%MVQ-M7%h%V2X__Volume:MAK_EnterpriseSN_TH
+G3K%h%NM-CH%h%G6T-R36X%h%3-9Q%h%DG6-8M%h%8K9______Retail_ProfessionalSingleLanguage
+HNG%h%CC-Y3%h%8KG-QVK8%h%D-WM%h%WRK-X8%h%6VK______Retail_ProfessionalCountrySpecific
+DXG%h%7C-N3%h%6C4-C4HT%h%G-X4%h%T3X-2Y%h%V77______Retail_ProfessionalWorkstation
+WYP%h%NQ-8C%h%467-V2W6%h%J-TX%h%4WX-WT%h%2RQ______Retail_ProfessionalWorkstationN
+8PT%h%T6-RN%h%W4C-6V7J%h%2-C2%h%D3X-MH%h%BPB______Retail_ProfessionalEducation
+GJT%h%YN-HD%h%MQY-FRR7%h%6-HV%h%GC7-QP%h%F8P______Retail_ProfessionalEducationN
+C4N%h%TJ-CX%h%6Q2-VXDM%h%R-XV%h%KGM-F9%h%DJC__Volume:MAK_EnterpriseG
+46P%h%N6-R9%h%BK9-CVHK%h%B-HW%h%Q9V-MB%h%JY8__Volume:MAK_EnterpriseGN
+NJC%h%F7-PW%h%8QT-3324%h%D-68%h%8JX-2Y%h%V66______Retail_ServerRdsh
+V3W%h%VW-N2%h%PV2-CGWC%h%3-34%h%QGF-VM%h%J2C______Retail_Cloud
+NH9%h%J3-68%h%WK7-6FB9%h%3-4K%h%3DF-DJ%h%4F6______Retail_CloudN
+2HN%h%6V-HG%h%TM8-6C97%h%C-RK%h%67V-JQ%h%PFD______Retail_CloudE
+XQQ%h%YW-NF%h%FMW-XJPB%h%H-K8%h%732-CK%h%FFD______OEM:DM_IoTEnterprise
+QPM%h%6N-7J%h%2WJ-P88H%h%H-P3%h%YRH-YY%h%74H__OEM:NONSLP_IoTEnterpriseS_VB
+KBN%h%8V-HF%h%GQ4-MGXV%h%D-34%h%7P6-PD%h%QGT_Volume:GVLK_IoTEnterpriseS_NI
+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 (
for /f "tokens=1-4 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C (
@@ -1001,17 +1020,18 @@ if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*. :: Only RS3 and older version keys (GVLK/Generic Retail) are stored here, later ones are extracted from the system itself
+set h=
for %%# in (
-WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY_RS1_ServerStandard%Cor%
-CB7KF-BWN84-R7R2Y-793K2-8XDDG_RS1_ServerDatacenter%Cor%
-JCKRF-N37P4-C2D82-9YXRT-4M63B_RS1_ServerSolution
-QN4C6-GBJD2-FB422-GHWJK-GJG2R_RS1_ServerCloudStorage
-VP34G-4NPPG-79JTQ-864T4-R3MQX_RS1_ServerAzureCor
-9JQNQ-V8HQ6-PKB8H-GGHRY-R62H6_RS1_ServerAzureNano
-VN8D3-PR82H-DB6BJ-J9P4M-92F6J_RS1_ServerStorageStandard
-48TQX-NVK3R-D8QR3-GTHHM-8FHXC_RS1_ServerStorageWorkgroup
-2HXDN-KRXHB-GPYC7-YCKFJ-7FVDG_RS3_ServerDatacenterACor
-PTXN8-JFHJM-4WC78-MPCBR-9W4KR_RS3_ServerStandardACor
+WC2%h%BQ-8N%h%RM3-FDD%h%YY-2B%h%FGV-KHK%h%QY_RS1_ServerStandard%Cor%
+CB7%h%KF-BW%h%N84-R7R%h%2Y-79%h%3K2-8XD%h%DG_RS1_ServerDatacenter%Cor%
+JCK%h%RF-N3%h%7P4-C2D%h%82-9Y%h%XRT-4M6%h%3B_RS1_ServerSolution
+QN4%h%C6-GB%h%JD2-FB4%h%22-GH%h%WJK-GJG%h%2R_RS1_ServerCloudStorage
+VP3%h%4G-4N%h%PPG-79J%h%TQ-86%h%4T4-R3M%h%QX_RS1_ServerAzureCor
+9JQ%h%NQ-V8%h%HQ6-PKB%h%8H-GG%h%HRY-R62%h%H6_RS1_ServerAzureNano
+VN8%h%D3-PR%h%82H-DB6%h%BJ-J9%h%P4M-92F%h%6J_RS1_ServerStorageStandard
+48T%h%QX-NV%h%K3R-D8Q%h%R3-GT%h%HHM-8FH%h%XC_RS1_ServerStorageWorkgroup
+2HX%h%DN-KR%h%XHB-GPY%h%C7-YC%h%KFJ-7FV%h%DG_RS3_ServerDatacenterACor
+PTX%h%N8-JF%h%HJM-4WC%h%78-MP%h%CBR-9W4%h%KR_RS3_ServerStandardACor
) do (
for /f "tokens=1-3 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C (
echo "%branch%" | find /i "%%B" 1>nul && (set "key=%%A")
|
