diff --git a/MAS/Separate-Files-Version/Change_Edition.cmd b/MAS/Separate-Files-Version/Change_Edition.cmd index 5622663..2e7b173 100644 --- a/MAS/Separate-Files-Version/Change_Edition.cmd +++ b/MAS/Separate-Files-Version/Change_Edition.cmd @@ -1,15 +1,12 @@ @set masver=2.6 -@setlocal DisableDelayedExpansion @echo off ::============================================================================ :: -:: This script is a part of 'Microsoft-Activation-Scripts' (MAS) project. -:: :: Homepage: mass grave[.]dev -:: Email: windowsaddict@protonmail.com +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -22,26 +19,32 @@ set _stg=0 ::======================================================================================================================================== -:: Set Path variable, it helps if it is misconfigured in the system +:: Set Environment variables, it helps if they are misconfigured in the system -set "PATH=%SystemRoot%\System32;%SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" +setlocal EnableExtensions +setlocal DisableDelayedExpansion + +set "PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" + +set "SysPath=%SystemRoot%\System32" +set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" if exist "%SystemRoot%\Sysnative\reg.exe" ( -set "PATH=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%PATH%" +set "SysPath=%SystemRoot%\Sysnative" +set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%" ) -:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows -:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows +set "ComSpec=%SysPath%\cmd.exe" +set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="r1" set r1=1 if /i "%%#"=="r2" set r2=1 -if /i "%%#"=="-qedit" ( -reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "1" /f %nul1% -rem check the code below admin elevation to understand why it's here -) ) +:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows +:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows + if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 ( setlocal EnableDelayedExpansion start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1" @@ -69,10 +72,10 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Help - %mas%troubleshoot.html +echo Help - %mas%troubleshoot echo: echo: -ping 127.0.0.1 -n 10 +ping 127.0.0.1 -n 20 ) cls @@ -81,9 +84,13 @@ cls pushd "%~dp0" >nul findstr /v "$" "%~nx0" && ( echo: -echo Error: Script either has LF line ending issue or an empty line at the end of the script is missing. +echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo: -ping 127.0.0.1 -n 6 >nul +echo: +echo Help - %mas%troubleshoot +echo: +echo: +ping 127.0.0.1 -n 20 >nul popd exit /b ) @@ -97,6 +104,7 @@ title Change Windows Edition %masver% set _args= set _elev= +set _unattended=0 set _args=%* if defined _args set _args=%_args:"=% @@ -111,37 +119,8 @@ set "nul2=2>nul" set "nul6=2^>nul" set "nul=>nul 2>&1" -set psc=powershell.exe -set winbuild=1 -for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G - -set _NCS=1 -if %winbuild% LSS 10586 set _NCS=0 -if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) - -if %_NCS% EQU 1 ( -for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" -set "Red="41;97m"" -set "Gray="100;97m"" -set "Green="42;97m"" -set "Blue="44;97m"" -set "_White="40;37m"" -set "_Green="40;92m"" -set "_Yellow="40;93m"" -) else ( -set "Red="Red" "white"" -set "Gray="Darkgray" "white"" -set "Green="DarkGreen" "white"" -set "Blue="Blue" "white"" -set "_White="Black" "Gray"" -set "_Green="Black" "Green"" -set "_Yellow="Black" "Yellow"" -) - -set "nceline=echo: &echo ==== ERROR ==== &echo:" -set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:" +call :dk_setvar set "line=echo ___________________________________________________________________________________________" -if %~z0 GEQ 200000 (set "_exitmsg=Go back") else (set "_exitmsg=Exit") ::======================================================================================================================================== @@ -149,13 +128,7 @@ if %winbuild% LSS 7600 ( %nceline% echo Unsupported OS version detected [%winbuild%]. echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalent. -goto ced_done -) - -for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" ( -%nceline% -echo Unable to find powershell.exe in the system. -goto ced_done +goto dk_done ) ::======================================================================================================================================== @@ -169,6 +142,7 @@ set "_batf=%~f0" set "_batp=%_batf:'=''%" set _PSarg="""%~f0""" -el %_args% +set _PSarg=%_PSarg:'=''% set "_ttemp=%userprofile%\AppData\Local\Temp" @@ -183,36 +157,89 @@ echo Script is launched from the temp folder, echo Most likely you are running the script directly from the archive file. echo: echo Extract the archive file and launch the script from the extracted folder. -goto ced_done +goto dk_done ) ) ::======================================================================================================================================== +:: Check PowerShell + +REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +call :dk_color %Blue% "Check if your antivirus is blocking the script." +echo: +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( -if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg:'=''!\"' -verb runas" && exit /b +if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg!\"' -verb runas" && exit /b %eline% echo This script needs admin rights. echo To do so, right click on this script and select 'Run as administrator'. -goto ced_done +goto dk_done ) ::======================================================================================================================================== -:: This code disables QuickEdit for this cmd.exe session only without making permanent changes to the registry -:: It is added because clicking on the script window pauses the operation and leads to the confusion that script stopped due to an error +:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app -for %%# in (%_args%) do (if /i "%%#"=="-qedit" set quedit=1) - -reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% || if not defined quedit ( -reg add HKCU\Console /v QuickEdit /t REG_DWORD /d "0" /f %nul1% -start cmd.exe /c ""!_batf!" %_args% -qedit" -rem quickedit reset code is added at the starting of the script instead of here because it takes time to reflect in some cases -exit /b +if %winbuild% GEQ 17763 ( +set terminal=1 +) else ( +set terminal= ) +:: Check if script is running in Terminal app + +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + +if defined terminal ( +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= +) + +if %_unattended%==1 goto :skipQE +for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) + +if defined terminal ( +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" +) + +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) +:skipQE + ::======================================================================================================================================== :: Check for updates @@ -227,9 +254,10 @@ if not [%%#]==[] (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.6 if defined old ( echo ________________________________________________ %eline% -echo You are running outdated version MAS %masver% +echo Version %masver% of MAS is outdated. echo ________________________________________________ echo: +if not %_unattended%==1 ( echo [1] Get Latest MAS echo [0] Continue Anyway echo: @@ -238,114 +266,109 @@ choice /C:10 /N if !errorlevel!==2 rem if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) ) +) + +::======================================================================================================================================== + +setlocal DisableDelayedExpansion + +:: Check desktop location + +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" +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 dk_done +) + +setlocal EnableDelayedExpansion ::======================================================================================================================================== cls -mode 98, 30 +if not defined terminal mode 98, 30 +title Change Windows Edition %masver% echo: echo Initializing... echo: -call :dk_product + +for %%# in ( +sppsvc.exe +dism.exe +) do ( +if not exist %SysPath%\%%# ( +%eline% +echo [%SysPath%\%%#] file is missing. Aborting... +echo: +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +goto dk_done +) +) + +::======================================================================================================================================== + +set spp=SoftwareLicensingProduct +set sps=SoftwareLicensingService + +call :dk_reflection call :dk_ckeckwmic +call :dk_sppissue -:: Show info for potential script stuck scenario - -sc start sppsvc %nul% -if %errorlevel% NEQ 1056 if %errorlevel% NEQ 0 ( -echo: -echo Error code: %errorlevel% -call :dk_color %Red% "Failed to start [sppsvc] service, rest of the process may take a long time..." -echo: +for /f "tokens=6-7 delims=[]. " %%i in ('ver') do if not "%%j"=="" ( +set fullbuild=%%i.%%j +) else ( +for /f "tokens=3" %%G in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR" %nul6%') do if not errorlevel 1 set /a "UBR=%%G" +for /f "skip=2 tokens=3,4 delims=. " %%G in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildLabEx') do ( +if defined UBR (set "fullbuild=%%G.!UBR!") else (set "fullbuild=%%G.%%H") +) ) ::======================================================================================================================================== -:: Check Activation IDs +:: Check Activation ID -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 -call :dk_actids -if not defined applist ( +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined apps ( %eline% -echo Activation IDs not found. Aborting... +echo Either key is not insalled or failed to get installed key activation ID. Aborting... echo: -echo Check this page for help. %mas%troubleshoot -goto ced_done -) +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +goto dk_done ) ::======================================================================================================================================== -call :dk_checksku +:: Check Windows Edition and branch -if not defined osSKU ( -%eline% -echo SKU value was not detected properly. Aborting... -goto ced_done -) - -::======================================================================================================================================== - -:: Check Windows Edition - -set osedition= +set osedition=0 set dismedition= set dismnotworking= -set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [int], @([String], [int], [int].MakeByRefType(), [String].MakeByRefType()), 1, 3); -set d1=%d1% $editionName = 0; [void]$TypeBuilder.CreateType()::SLGetWindowsInformation('Kernel-EditionName', 0, [ref]0, [ref]$editionName); $editionName -if %winbuild% GEQ 14393 for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set osedition=%%s) -if "%osedition%"=="0" set osedition= +if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL) get LicenseFamily /VALUE" %nul6%')" +if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')" +%chkedi% do if not errorlevel 1 (call set "osedition=%%a") -if not defined osedition ( -for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "osedition=%%a" +if %osedition%==0 ( +%eline% +echo Failed to detect OS Edition. Aborting... +echo: +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +goto dk_done ) -:: Workaround for an issue in builds between 1607 and 1709 where ProfessionalEducation is shown as Professional - -if %osSKU%==164 set osedition=ProfessionalEducation -if %osSKU%==165 set osedition=ProfessionalEducationN - for /f "tokens=3 delims=: " %%a in ('DISM /English /Online /Get-CurrentEdition %nul6% ^| find /i "Current Edition :"') do set "dismedition=%%a" if not defined dismedition set dismnotworking=1 -if defined dismedition if not defined osedition set osedition=%dismedition% - -if not defined osedition ( -%eline% -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. %mas%troubleshoot -goto ced_done -) - -::======================================================================================================================================== - set branch= for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildBranch %nul6%') do set "branch=%%b" -:: Check PowerShell - -%psc% $ExecutionContext.SessionState.LanguageMode %nul2% | find /i "Full" %nul1% || ( -%eline% -%psc% $ExecutionContext.SessionState.LanguageMode -echo: -echo PowerShell is not working. Aborting... -echo If you have applied restrictions on Powershell then undo those changes. -echo: -echo Check this page for help. %mas%troubleshoot -goto ced_done -) - ::======================================================================================================================================== :: Get Target editions list @@ -361,20 +384,25 @@ if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[io.file]::ReadAllT if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( call :ced_edilist -if /i "%osedition:~0,4%"=="Core" (set "_wtarget= Professional !_wtarget! ") -set "_dtarget= %_dtarget% !_wtarget! " +if /i "%osedition:~0,4%"=="Core" set _pro=Professional +if /i "%osedition%"=="CoreN" set _pro=ProfessionalN +set "_dtarget= %_dtarget% !_wtarget! !_pro! " ) ::======================================================================================================================================== -:: Block the change to/from CloudEdition editions - -for %%# in (202 203) do if %osSKU%==%%# ( -%eline% -echo [%winos% ^| SKU:%osSKU% ^| %winbuild%] -echo It's not recommended to change this installed edition to any other. -echo Aborting... -goto ced_done +for %%# in (CloudEdition CloudEditionN ServerRdsh) do if /i %osedition%==%%# ( +cls +echo: +call :dk_color %Red% "==== Note ====" +echo: +echo [EditionID:%osedition% ^| %fullbuild%] +echo: +echo Changing this edition to any other may not remove "%osedition%" specific features. +echo: +call :dk_color %_Yellow% "Press 7 key to continue..." +choice /c 7 /n +cls ) for %%# in ( %_dtarget% %_ptarget% ) do if /i not "%%#"=="%osedition%" ( @@ -383,18 +411,18 @@ echo "!_target!" | find /i " %%# " %nul1% || set "_target= !_target! %%# " if defined _target ( for %%# in (%_target%) do ( -echo %%# | findstr /i "CountrySpecific CloudEdition ServerRdsh" %nul% || (set "_ntarget=!_ntarget! %%#") +echo %%# | findstr /i "CountrySpecific CloudEdition" %nul% || (set "_ntarget=!_ntarget! %%#") ) ) if not defined _ntarget ( %line% echo: -if defined dismnotworking call :dk_color %Red% "DISM.exe is not responding." +if defined dismnotworking call :dk_color %Red% "DISM.exe is not working." call :dk_color %Gray% "Target Edition not found." echo Current Edition [%osedition% ^| %winbuild%] can not be changed to any other Edition. %line% -goto ced_done +goto dk_done ) ::======================================================================================================================================== @@ -402,7 +430,7 @@ goto ced_done :cedmenu2 cls -mode 98, 30 +if not defined terminal mode 98, 30 set inpt= set counter=0 set verified=0 @@ -410,9 +438,9 @@ set targetedition= %line% echo: -call :dk_color %Gray% "You can change the Edition [%osedition%] [%winbuild%] to one of the following." +call :dk_color %Gray% "You can change the Edition [%osedition%] [%fullbuild%] to one of the following." if defined dismnotworking ( -call :dk_color %_Yellow% "Note - DISM.exe is not responding." +call :dk_color %_Yellow% "Note - DISM.exe is not working." if /i "%osedition:~0,4%"=="Core" call :dk_color %_Yellow% " - You will see more edition options to choose once its changed to Pro." ) %line% @@ -442,17 +470,36 @@ if %winbuild% LSS 10240 goto :cbsmethod if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" goto :ced_change_server cls -mode con cols=105 lines=32 +if not defined terminal mode con cols=105 lines=32 +if /i "%targetedition%"=="ServerRdsh" ( +echo: +call :dk_color %Red% "==== Note ====" +echo: +echo Once the edition is changed to "%targetedition%", +echo system may not be able to properly change edition to any other later. +echo: +echo [1] Continue +echo [0] Go Back +echo: +call :dk_color %_Green% "Enter a menu option in the Keyboard [1,0] :" +choice /C:10 /N +if !errorlevel!==2 goto cedmenu2 +if !errorlevel!==1 rem +) + +cls set key= set _chan= set _dismapi=0 :: Check if DISM Api or slmgr.vbs is required for edition upgrade -if not exist "%SystemRoot%\System32\spp\tokens\skus\%targetedition%\" ( +if not exist "%SysPath%\spp\tokens\skus\%targetedition%\" ( +echo %_wtarget% | find /i " %targetedition% " || ( set _dismapi=1 ) +) set "keyflow=Retail OEM:NONSLP OEM:DM Volume:MAK Volume:GVLK" @@ -460,14 +507,19 @@ call :ced_targetSKU %targetedition% 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 if %_dismapi%==1 if /i "%targetedition%"=="Professional" ( +set key=VK7JG-NPHTM-C97JM-9MPGT-3V6%h%6T +set _chan=Retail +) if not defined key ( %eline% echo [%targetedition% ^| %winbuild%] echo Unable to get product key from pkeyhelper.dll echo: -echo Check this page for help. %mas%troubleshoot -goto ced_done +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +goto dk_done ) ::======================================================================================================================================== @@ -476,21 +528,16 @@ goto ced_done :: In other cases, editions can be changed instantly with "slmgr /ipk" if %_dismapi%==1 ( -mode con cols=105 lines=40 -%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':checkrebootflag\:.*';iex ($f[1]);" | find /i "True" %nul% && ( -%eline% -echo Pending Reboot flags found. -echo: -echo Restart the system and try again. -goto ced_done -) +if not defined terminal mode con cols=105 lines=40 +call :ced_rebootflag +if defined rebootreq goto dk_done ) cls %line% echo: -if defined dismnotworking call :dk_color %_Yellow% "DISM.exe is not responding." -echo Changing the Current Edition [%osedition%] %winbuild% to [%targetedition%] +if defined dismnotworking call :dk_color %_Yellow% "DISM.exe is not working." +echo Changing the Current Edition [%osedition%] %fullbuild% to [%targetedition%] echo: if %_dismapi%==1 ( @@ -510,22 +557,22 @@ if !errorlevel!==1 exit /b if %_dismapi%==0 ( echo Installing %_chan% Key [%key%] echo: -if %_wmic% EQU 1 wmic path SoftwareLicensingService where __CLASS='SoftwareLicensingService' call InstallProductKey ProductKey="%key%" %nul% -if %_wmic% EQU 0 %psc% "(([WMISEARCHER]'SELECT Version FROM SoftwareLicensingService').Get()).InstallProductKey('%key%')" %nul% -if not !errorlevel!==0 cscript //nologo %windir%\system32\slmgr.vbs /ipk %key% %nul% +if %_wmic% EQU 1 wmic path %sps% where __CLASS='%sps%' call InstallProductKey ProductKey="%key%" %nul% +if %_wmic% EQU 0 %psc% "try { $null=(([WMISEARCHER]'SELECT Version FROM %sps%').Get()).InstallProductKey('%key%'); exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul% +set keyerror=!errorlevel! +cmd /c exit /b !keyerror! +if !keyerror! NEQ 0 set "keyerror=[0x!=ExitCode!]" -set error_code=!errorlevel! -cmd /c exit /b !error_code! -if !error_code! NEQ 0 set "error_code=[0x!=ExitCode!]" - -if !error_code! EQU 0 ( +if !keyerror! EQU 0 ( call :dk_refresh call :dk_color %Green% "[Successful]" echo: call :dk_color %Gray% "Reboot is required to properly change the Edition." ) else ( -call :dk_color %Red% "[Unsuccessful] [Error Code: 0x!=ExitCode!]" -echo Check this page for help. %mas%troubleshoot +call :dk_color %Red% "[Unsuccessful] [Error Code: !keyerror!]" +echo: +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) ) @@ -533,34 +580,33 @@ if %_dismapi%==1 ( echo: echo Applying the DISM API method with %_chan% Key %key%. Please wait... echo: -%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':dismapi\:.*';& ([ScriptBlock]::Create($f[1])) %targetedition% %key%;" -timeout /t 3 %nul1% -echo: -call :dk_color2 %Blue% "Check this page for help" %_Yellow% " %mas%change_edition_issues" + +call :ced_prep +if defined preperror goto dk_done + +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':dismapi\:.*';& ([ScriptBlock]::Create($f[1])) %targetedition% %key%" +call :ced_postprep ) %line% -goto ced_done +goto dk_done ::======================================================================================================================================== :cbsmethod cls +if not defined terminal ( mode con cols=105 lines=32 %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;}" +) -REM %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':checkrebootflag\:.*';iex ($f[1]);" | find /i "True" %nul% && ( -REM %eline% -REM echo Pending reboot flags found. -REM echo: -REM echo Restart the system and try again. -REM goto ced_done -REM ) +call :ced_rebootflag +if defined rebootreq goto dk_done echo: -if defined dismnotworking call :dk_color %_Yellow% "Note - DISM.exe is not responding." -echo Changing the Current Edition [%osedition%] %winbuild% to [%targetedition%] +if defined dismnotworking call :dk_color %_Yellow% "Note - DISM.exe is not working." +echo Changing the Current Edition [%osedition%] %fullbuild% to [%targetedition%] echo: call :dk_color %Blue% "Important - Save your work before continue, system will auto reboot." echo: @@ -571,22 +617,25 @@ echo: echo Initializing... echo: +call :ced_prep +if defined preperror goto dk_done + 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: -call :dk_color %Blue% "Incase of errors, you must restart your system before trying again." -echo Check this page for help. %mas%troubleshoot +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -SetEdition %targetedition% %stage%" +call :ced_postprep %line% -goto ced_done +goto dk_done ::======================================================================================================================================== :ced_change_server cls +if not defined terminal ( mode con cols=105 lines=32 %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;}" +) set key= set _chan= @@ -602,97 +651,168 @@ if not defined key ( echo [%targetedition% ^| %winbuild%] echo Unable to get product key from pkeyhelper.dll echo: -echo Check this page for help. %mas%troubleshoot -goto ced_done +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +goto dk_done ) -::======================================================================================================================================== - -%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':checkrebootflag\:.*';iex ($f[1]);" | find /i "True" %nul% && ( -%eline% -echo Pending reboot flags found. -echo: -echo Restart the system and try again. -goto ced_done -) +call :ced_rebootflag +if defined rebootreq goto dk_done cls echo: -if defined dismnotworking call :dk_color %_Yellow% "Note - DISM.exe is not responding." -echo Changing the Current Edition [%osedition%] %winbuild% to [%targetedition%] +if defined dismnotworking call :dk_color %_Yellow% "Note - DISM.exe is not working." +echo Changing the Current Edition [%osedition%] %fullbuild% to [%targetedition%] echo: + +call :ced_prep +if defined preperror goto dk_done + echo Applying the command with %_chan% Key echo DISM /online /Set-Edition:%targetedition% /ProductKey:%key% /AcceptEula DISM /online /Set-Edition:%targetedition% /ProductKey:%key% /AcceptEula -call :dk_color %Blue% "You must restart the system at this stage." -echo Help: %mas%troubleshoot +call :ced_postprep ::======================================================================================================================================== -:ced_done +:ced_prep + +set _time= +set preperror= + +for /f %%a in ('%psc% "(Get-Date).ToString('yyyyMMdd-HHmmssfff')"') do set _time=%%a + +if not defined _time ( +%eline% +echo Failed to get time with Powershell command. +set preperror=1 +exit /b +) + +%psc% Stop-Service TrustedInstaller -force %nul% +%psc% Stop-Service TrustedInstaller -force %nul% + +sc query TrustedInstaller | find /i "RUNNING" %nul% && ( +%eline% +echo Failed to stop TrustedInstaller service. +echo Try again or Restart your system and then try again. +set preperror=1 +exit /b +) + +copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "%SystemRoot%\logs\cbs\backup_cbs_%_time%.log" %nul% +copy /y /b "%SystemRoot%\logs\DISM\dism.log" "%SystemRoot%\logs\DISM\backup_dism_%_time%.log" %nul% + +del /f /q "%SystemRoot%\logs\cbs\cbs.log" %nul% +del /f /q "%SystemRoot%\logs\DISM\dism.log" %nul% + +for %%# in (%SystemRoot%\logs\cbs\cbs.log %SystemRoot%\logs\DISM\dism.log) do if exist %%# ( +%eline% +echo Failed to backup and delete %%# +echo Try again or Restart your system and then try again. +set preperror=1 +exit /b +) + +:: Initiate this to appear in fresh logs + +dism /online /english /Get-CurrentEdition %nul% +dism /online /english /Get-TargetEditions %nul% +exit /b + +::======================================================================================================================================== + +:ced_postprep + +timeout /t 5 %nul1% + +if not exist "!desktop!\ChangeEdition_Logs\" md "!desktop!\ChangeEdition_Logs\" %nul% +copy /y /b "%SystemRoot%\logs\cbs\cbs.log" "!desktop!\ChangeEdition_Logs\CBS_%_time%.log" %nul% +copy /y /b "%SystemRoot%\logs\DISM\dism.log" "!desktop!\ChangeEdition_Logs\DISM_%_time%.log" %nul% echo: -call :dk_color %_Yellow% "Press any key to %_exitmsg%..." -pause %nul1% +echo Log files are copied to the ChangeEdition_Logs folder on the dekstop. +echo: +call :dk_color %Blue% "In case of errors, you must restart your system before trying again." +echo: +set fixes=%fixes% %mas%change_edition_issues +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%change_edition_issues" exit /b ::======================================================================================================================================== -:: Check SKU value +:: Set variables -:dk_checksku +:dk_setvar -set osSKU= -set slcSKU= -set wmiSKU= -set regSKU= +set psc=powershell.exe +set winbuild=1 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G -if %winbuild% GEQ 14393 (set info=Kernel-BrandingInfo) else (set info=Kernel-ProductInfo) -set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 'Public, Static', 1, [int], @([String], [int].MakeByRefType()), 1, 3); -set d1=%d1% $Sku = 0; [void]$TypeBuilder.CreateType()::SLGetWindowsInformationDWORD('%info%', [ref]$Sku); $Sku -for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set slcSKU=%%s) -if "%slcSKU%"=="0" set slcSKU= -if 1%slcSKU% NEQ +1%slcSKU% set slcSKU= +set _NCS=1 +if %winbuild% LSS 10586 set _NCS=0 +if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) -for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" /v OSProductPfn %nul6%') do set "regSKU=%%a" -if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" -if %_wmic% EQU 0 for /f "tokens=1" %%a in ('%psc% "([WMI]'Win32_OperatingSystem=@').OperatingSystemSKU" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" +if %_NCS% EQU 1 ( +for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" +set "Red="41;97m"" +set "Gray="100;97m"" +set "Green="42;97m"" +set "Blue="44;97m"" +set "_Red="40;91m"" +set "_White="40;37m"" +set "_Green="40;92m"" +set "_Yellow="40;93m"" +) else ( +set "Red="Red" "white"" +set "Gray="Darkgray" "white"" +set "Green="DarkGreen" "white"" +set "Blue="Blue" "white"" +set "_Red="Black" "Red"" +set "_White="Black" "Gray"" +set "_Green="Black" "Green"" +set "_Yellow="Black" "Yellow"" +) -set osSKU=%slcSKU% -if not defined osSKU set osSKU=%wmiSKU% -if not defined osSKU set osSKU=%regSKU% +set "nceline=echo: &echo ==== ERROR ==== &echo:" +set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:" +if %~z0 GEQ 200000 ( +set "_exitmsg=Go back" +set "_fixmsg=Go back to Main Menu, select Troubleshoot and run Fix Licensing option." +) else ( +set "_exitmsg=Exit" +set "_fixmsg=In MAS folder, run Troubleshoot script and select Fix Licensing option." +) exit /b +::======================================================================================================================================== + :: Refresh license status :dk_refresh -if %_wmic% EQU 1 wmic path SoftwareLicensingService where __CLASS='SoftwareLicensingService' call RefreshLicenseStatus %nul% -if %_wmic% EQU 0 %psc% "$null=(([WMICLASS]'SoftwareLicensingService').GetInstances()).RefreshLicenseStatus()" %nul% +if %_wmic% EQU 1 wmic path %sps% where __CLASS='%sps%' call RefreshLicenseStatus %nul% +if %_wmic% EQU 0 %psc% "$null=(([WMICLASS]'%sps%').GetInstances()).RefreshLicenseStatus()" %nul% exit /b -:: Get Windows Activation IDs +:: Get installed products Activation IDs -:dk_actids +:dk_actid -set applist= -if %_wmic% EQU 1 set "chkapp=for /f "tokens=2 delims==" %%a in ('"wmic path SoftwareLicensingProduct where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f') get ID /VALUE" %nul6%')" -if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM SoftwareLicensingProduct WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f''').Get()).ID ^| %% {echo ('ID='+$_)}" %nul6%')" -%chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a")) +set apps= +if %_wmic% EQU 1 set "chkapp=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='%1' and PartialProductKey is not null) get ID /VALUE" %nul6%')" +if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %spp% WHERE ApplicationID=''%1'' AND PartialProductKey IS NOT NULL').Get()).ID ^| %% {echo ('ID='+$_)}" %nul6%')" +%chkapp% do (if defined apps (call set "apps=!apps! %%a") else (call set "apps=%%a")) exit /b :: Get Edition list :ced_edilist -if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path SoftwareLicensingProduct where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f') get LicenseFamily /VALUE" %nul6%')" -if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM SoftwareLicensingProduct WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f''').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')" -%chkedi% do ( -call if exist %Systemdrive%\Windows\System32\spp\tokens\skus\%%a ( -call set "_wtarget= !_wtarget! %%a " -) -) +if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseDependsOn is NULL) get LicenseFamily /VALUE" %nul6%')" +if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND LicenseDependsOn is NULL').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')" +%chkedi% do call set "_wtarget= !_wtarget! %%a " exit /b :: Check wmic.exe @@ -705,23 +825,20 @@ wmic path Win32_ComputerSystem get CreationClassName /value %nul2% | find /i "co ) exit /b -:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) +:: Show info for potential script stuck scenario -:dk_product +:dk_sppissue -call :dk_reflection +sc start sppsvc %nul% +set spperror=%errorlevel% -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= -for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) -echo "%winos%" | find /i "Windows" %nul1% || ( -for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName %nul6%') do set "winos=%%b" -if %winbuild% GEQ 22000 ( -set winos=!winos:Windows 10=Windows 11! -) +if %spperror% NEQ 1056 if %spperror% NEQ 0 ( +%eline% +echo sc start sppsvc [Error Code: %spperror%] ) + +echo: +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 20)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}" exit /b :: Common lines used in PowerShell reflection code @@ -737,31 +854,26 @@ exit /b :: Check pending reboot flags -:checkrebootflag: -function Test-PendingReboot -{ - if (Test-Path -Path "$env:windir\WinSxS\pending.xml") { return $true } - if (Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -EA SilentlyContinue) { return $true } - if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -EA SilentlyContinue) { return $true } - try { - $util = [wmiclass]"\\.\root\ccm\clientsdk:CCM_ClientUtilities" - $status = $util.DetermineIfRebootPending() - if(($status -ne $null) -and $status.RebootPending){ - return $true - } - }catch{} - - return $false -} -Test-PendingReboot -:checkrebootflag: +:ced_rebootflag + +set rebootreq= +reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" %nul% && set rebootreq=1 +reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" %nul% && set rebootreq=1 + +if defined rebootreq ( +%eline% +echo Pending Reboot flags found. +echo: +echo Make sure Windows is fully updated, restart the system and try again. +) +exit /b ::======================================================================================================================================== :: Get Product Key from pkeyhelper.dll for future new editions :: It works on Windows 10 1803 (17134) and later builds. -:dk_pkey +:k_pkey call :dk_reflection @@ -772,14 +884,13 @@ set pkey= 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 +:k_pkeychannel set k=%1 set m=[Runtime.InteropServices.Marshal] -set p=%SystemRoot%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms +set p=$env:SysPath\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms 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); @@ -793,8 +904,8 @@ exit /b for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b for %%# in (%keyflow%) do ( -call :dk_pkey %targetSKU% '%%#' -if defined pkey call :dk_pkeychannel !pkey! +call :k_pkey %targetSKU% '%%#' +if defined pkey call :k_pkeychannel !pkey! if /i [!pkeychannel!]==[%%#] ( set key=!pkey! exit /b @@ -841,6 +952,29 @@ exit /b ::======================================================================================================================================== +:dk_done + +echo: +if %_unattended%==1 timeout /t 2 & exit /b + +if defined fixes ( +call :dk_color2 %Blue% "Press [1] To Open Troubleshoot Page " %Gray% " Press [0] To Ignore" +choice /C:10 /N +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) +) + +if defined terminal ( +call :dk_color %_Yellow% "Press 0 key to %_exitmsg%..." +choice /c 0 /n +) else ( +call :dk_color %_Yellow% "Press any key to %_exitmsg%..." +pause %nul1% +) + +exit /b + +::======================================================================================================================================== + :: https://github.com/Gamers-Against-Weed/Set-WindowsCbsEdition :cbsxml:[ @@ -1113,45 +1247,45 @@ if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*. set h= for %%# in ( -XGV%h%PP-NM%h%H47-7TT%h%HJ-W%h%3FW7-8HV%h%2C__OEM:NONSLP_Enterprise -D6R%h%D9-D4%h%N8T-RT9%h%QX-Y%h%W6YT-FCW%h%WJ______Retail_Starter -3V6%h%Q6-NQ%h%XCX-V8Y%h%XR-9%h%QCYV-QPF%h%CT__Volume:MAK_EnterpriseN -3NF%h%XW-2T%h%27M-2BD%h%W6-4%h%GHRV-68X%h%RX______Retail_StarterN -VK7%h%JG-NP%h%HTM-C97%h%JM-9%h%MPGT-3V6%h%6T______Retail_Professional -2B8%h%7N-8K%h%FHP-DKV%h%6R-Y%h%2C8J-PKC%h%KT______Retail_ProfessionalN -4CP%h%RK-NM%h%3K3-X6X%h%XQ-R%h%XX86-WXC%h%HW______Retail_CoreN -N24%h%34-X9%h%D7W-8PF%h%6X-8%h%DV9T-8TY%h%MD______Retail_CoreCountrySpecific -BT7%h%9Q-G7%h%N6G-PGB%h%YW-4%h%YWX6-6F4%h%BT______Retail_CoreSingleLanguage -YTM%h%G3-N6%h%DKC-DKB%h%77-7%h%M9GH-8HV%h%X7______Retail_Core -XKC%h%NC-J2%h%6Q9-KFH%h%D2-F%h%KTHY-KD7%h%2Y__OEM:NONSLP_PPIPro -YNM%h%GQ-8R%h%YV3-4PG%h%Q3-C%h%8XTP-7CF%h%BY______Retail_Education -84N%h%GF-MH%h%BT6-FXB%h%X8-Q%h%WJK7-DRR%h%8H______Retail_EducationN -NK9%h%6Y-D9%h%CD8-W44%h%CQ-R%h%8YTK-DYJ%h%WX__OEM:NONSLP_EnterpriseS_RS1 -FWN%h%7H-PF%h%93Q-4GG%h%P8-M%h%8RF3-MDW%h%WW__OEM:NONSLP_EnterpriseS_TH -2DB%h%W3-N2%h%PJG-MVH%h%W3-G%h%7TDK-9HK%h%R4__Volume:MAK_EnterpriseSN_RS1 -NTX%h%6B-BR%h%YC2-K67%h%86-F%h%6MVQ-M7V%h%2X__Volume:MAK_EnterpriseSN_TH -G3K%h%NM-CH%h%G6T-R36%h%X3-9%h%QDG6-8M8%h%K9______Retail_ProfessionalSingleLanguage -HNG%h%CC-Y3%h%8KG-QVK%h%8D-W%h%MWRK-X86%h%VK______Retail_ProfessionalCountrySpecific -DXG%h%7C-N3%h%6C4-C4H%h%TG-X%h%4T3X-2YV%h%77______Retail_ProfessionalWorkstation -WYP%h%NQ-8C%h%467-V2W%h%6J-T%h%X4WX-WT2%h%RQ______Retail_ProfessionalWorkstationN -8PT%h%T6-RN%h%W4C-6V7%h%J2-C%h%2D3X-MHB%h%PB______Retail_ProfessionalEducation -GJT%h%YN-HD%h%MQY-FRR%h%76-H%h%VGC7-QPF%h%8P______Retail_ProfessionalEducationN -C4N%h%TJ-CX%h%6Q2-VXD%h%MR-X%h%VKGM-F9D%h%JC__Volume:MAK_EnterpriseG -46P%h%N6-R9%h%BK9-CVH%h%KB-H%h%WQ9V-MBJ%h%Y8__Volume:MAK_EnterpriseGN -NJC%h%F7-PW%h%8QT-332%h%4D-6%h%88JX-2YV%h%66______Retail_ServerRdsh -V3W%h%VW-N2%h%PV2-CGW%h%C3-3%h%4QGF-VMJ%h%2C______Retail_Cloud -NH9%h%J3-68%h%WK7-6FB%h%93-4%h%K3DF-DJ4%h%F6______Retail_CloudN -2HN%h%6V-HG%h%TM8-6C9%h%7C-R%h%K67V-JQP%h%FD______Retail_CloudE -WC2%h%BQ-8N%h%RM3-FDD%h%YY-2%h%BFGV-KHK%h%QY_Volume:GVLK_ServerStandard%Cor%_RS1 -CB7%h%KF-BW%h%N84-R7R%h%2Y-7%h%93K2-8XD%h%DG_Volume:GVLK_ServerDatacenter%Cor%_RS1 -JCK%h%RF-N3%h%7P4-C2D%h%82-9%h%YXRT-4M6%h%3B_Volume:GVLK_ServerSolution_RS1 -QN4%h%C6-GB%h%JD2-FB4%h%22-G%h%HWJK-GJG%h%2R_Volume:GVLK_ServerCloudStorage_RS1 -VP3%h%4G-4N%h%PPG-79J%h%TQ-8%h%64T4-R3M%h%QX_Volume:GVLK_ServerAzureCor_RS1 -9JQ%h%NQ-V8%h%HQ6-PKB%h%8H-G%h%GHRY-R62%h%H6______Retail_ServerAzureNano_RS1 -VN8%h%D3-PR%h%82H-DB6%h%BJ-J%h%9P4M-92F%h%6J______Retail_ServerStorageStandard_RS1 -48T%h%QX-NV%h%K3R-D8Q%h%R3-G%h%THHM-8FH%h%XC______Retail_ServerStorageWorkgroup_RS1 -2HX%h%DN-KR%h%XHB-GPY%h%C7-Y%h%CKFJ-7FV%h%DG_Volume:GVLK_ServerDatacenterACor_RS3 -PTX%h%N8-JF%h%HJM-4WC%h%78-M%h%PCBR-9W4%h%KR_Volume:GVLK_ServerStandardACor_RS3 +XGVPP-NMH47-7TTHJ-W3FW7-8HV%h%2C__OEM:NONSLP_Enterprise +D6RD9-D4N8T-RT9QX-YW6YT-FCW%h%WJ______Retail_Starter +3V6Q6-NQXCX-V8YXR-9QCYV-QPF%h%CT__Volume:MAK_EnterpriseN +3NFXW-2T27M-2BDW6-4GHRV-68X%h%RX______Retail_StarterN +VK7JG-NPHTM-C97JM-9MPGT-3V6%h%6T______Retail_Professional +2B87N-8KFHP-DKV6R-Y2C8J-PKC%h%KT______Retail_ProfessionalN +4CPRK-NM3K3-X6XXQ-RXX86-WXC%h%HW______Retail_CoreN +N2434-X9D7W-8PF6X-8DV9T-8TY%h%MD______Retail_CoreCountrySpecific +BT79Q-G7N6G-PGBYW-4YWX6-6F4%h%BT______Retail_CoreSingleLanguage +YTMG3-N6DKC-DKB77-7M9GH-8HV%h%X7______Retail_Core +XKCNC-J26Q9-KFHD2-FKTHY-KD7%h%2Y__OEM:NONSLP_PPIPro +YNMGQ-8RYV3-4PGQ3-C8XTP-7CF%h%BY______Retail_Education +84NGF-MHBT6-FXBX8-QWJK7-DRR%h%8H______Retail_EducationN +NK96Y-D9CD8-W44CQ-R8YTK-DYJ%h%WX__OEM:NONSLP_EnterpriseS_RS1 +FWN7H-PF93Q-4GGP8-M8RF3-MDW%h%WW__OEM:NONSLP_EnterpriseS_TH +2DBW3-N2PJG-MVHW3-G7TDK-9HK%h%R4__Volume:MAK_EnterpriseSN_RS1 +NTX6B-BRYC2-K6786-F6MVQ-M7V%h%2X__Volume:MAK_EnterpriseSN_TH +G3KNM-CHG6T-R36X3-9QDG6-8M8%h%K9______Retail_ProfessionalSingleLanguage +HNGCC-Y38KG-QVK8D-WMWRK-X86%h%VK______Retail_ProfessionalCountrySpecific +DXG7C-N36C4-C4HTG-X4T3X-2YV%h%77______Retail_ProfessionalWorkstation +WYPNQ-8C467-V2W6J-TX4WX-WT2%h%RQ______Retail_ProfessionalWorkstationN +8PTT6-RNW4C-6V7J2-C2D3X-MHB%h%PB______Retail_ProfessionalEducation +GJTYN-HDMQY-FRR76-HVGC7-QPF%h%8P______Retail_ProfessionalEducationN +C4NTJ-CX6Q2-VXDMR-XVKGM-F9D%h%JC__Volume:MAK_EnterpriseG +46PN6-R9BK9-CVHKB-HWQ9V-MBJ%h%Y8__Volume:MAK_EnterpriseGN +NJCF7-PW8QT-3324D-688JX-2YV%h%66______Retail_ServerRdsh +V3WVW-N2PV2-CGWC3-34QGF-VMJ%h%2C______Retail_Cloud +NH9J3-68WK7-6FB93-4K3DF-DJ4%h%F6______Retail_CloudN +2HN6V-HGTM8-6C97C-RK67V-JQP%h%FD______Retail_CloudE +WC2BQ-8NRM3-FDDYY-2BFGV-KHK%h%QY_Volume:GVLK_ServerStandard%Cor%_RS1 +CB7KF-BWN84-R7R2Y-793K2-8XD%h%DG_Volume:GVLK_ServerDatacenter%Cor%_RS1 +JCKRF-N37P4-C2D82-9YXRT-4M6%h%3B_Volume:GVLK_ServerSolution_RS1 +QN4C6-GBJD2-FB422-GHWJK-GJG%h%2R_Volume:GVLK_ServerCloudStorage_RS1 +VP34G-4NPPG-79JTQ-864T4-R3M%h%QX_Volume:GVLK_ServerAzureCor_RS1 +9JQNQ-V8HQ6-PKB8H-GGHRY-R62%h%H6______Retail_ServerAzureNano_RS1 +VN8D3-PR82H-DB6BJ-J9P4M-92F%h%6J______Retail_ServerStorageStandard_RS1 +48TQX-NVK3R-D8QR3-GTHHM-8FH%h%XC______Retail_ServerStorageWorkgroup_RS1 +2HXDN-KRXHB-GPYC7-YCKFJ-7FV%h%DG_Volume:GVLK_ServerDatacenterACor_RS3 +PTXN8-JFHJM-4WC78-MPCBR-9W4%h%KR_Volume:GVLK_ServerStandardACor_RS3 ) do ( for /f "tokens=1-4 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C (