From 157ed8df1d73b090712f151c774063224890416c Mon Sep 17 00:00:00 2001
From: davidenco <davidenco@users.noreply.github.com>
Date: Tue, 3 Jan 2023 12:59:38 +0000
Subject: [PATCH] Add Windows 10/11 22H2

---
 MediaCreationTool.bat | 45 ++++++++++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 15 deletions(-)

diff --git a/MediaCreationTool.bat b/MediaCreationTool.bat
index 1723367..1f56745 100644
--- a/MediaCreationTool.bat
+++ b/MediaCreationTool.bat
@@ -1,14 +1,14 @@
 @goto latest at github.com/AveYo/MediaCreationTool.bat
-:Universal MCT wrapper script for all Windows 10/11 versions from 1507 to 21H2!
+:Universal MCT wrapper script for all Windows 10/11 versions from 1507 to 22H2!
 :: Nothing but Microsoft-hosted source links and no third-party tools; script just configures an xml and starts MCT
 :: Ingenious support for business editions (Enterprise / VL) selecting language, x86, x64 or AiO inside the MCT GUI
-:: Changelog: 2022.03.20 stable
-:: - all issues ironed out; upgrade keeping files from Eval editions too; pickup $ISO$ dir content to add on media
-:: - DU in 11: auto installs 22000.556 atm; older skip_11_checks, without Server label; Home offline local account
-:: on upgrade: latest build, on offline install: 11 22000.318 / 21H2 19044.1288 / 21H1 19043.1348 / 20H2 19042.1052
+:: Changelog: 2023.01.03 stable
+:: - added Windows 10 22H2
+:: - added Windows 11 22H2 (from Andrysky merge)
+:: on upgrade: latest build, on offline install: 11 22621.525 / 22H2 19045.2006 / 21H1 19043.1348 / 20H2 19042.1052
 
-::# uncomment to skip GUI dialog for MCT choice: 1507 to 2109 / 11 - or rename script: "21H2 MediaCreationTool.bat"
-rem set MCT=2110
+::# uncomment to skip GUI dialog for MCT choice: 1507 to 2109 / 11 - or rename script: "22H2 MediaCreationTool.bat"
+rem set MCT=2209
 
 ::# uncomment to start auto upgrade setup directly (no prompts) - or rename script: "auto 11 MediaCreationTool.bat"
 rem set /a AUTO=1
@@ -28,7 +28,7 @@ rem set ARCH=x64
 ::# uncomment and change autodetected KEY - or rename script / provide via commandline - not needed for generic key
 rem set KEY=NPPR9-FWDCX-D2C8J-H872K-2YT43
 
-::# uncomment to disable dynamic update for setup sources - or rename script: no_update 21H2 MediaCreationTool.bat"
+::# uncomment to disable dynamic update for setup sources - or rename script: no_update 22H2 MediaCreationTool.bat"
 rem set /a NO_UPDATE=1
 
 ::# uncomment to not add EI.cfg PID.txt auto.cmd $ISO$ dir content - or rename script:  "def MediaCreationTool.bat"
@@ -44,12 +44,12 @@ set OPTIONS=%OPTIONS% /Telemetry Disable /CompactOS Disable
 ::# comment to not unhide Enterprise for 1709+ in products.xml
 set /a UNHIDE_BUSINESS=1
 
-::# comment to not insert Enterprise esd links for 1607,1703 or update links for 1909,2004,20H2,21H2,11 in products.xml
+::# comment to not insert Enterprise esd links for 1607,1703 or update links for 1909,2004,20H2,21H2,22H2,11 in products.xml
 set /a INSERT_BUSINESS=1
 
 ::# MCT Version choice dialog items and default-index [11]
-set VERSIONS=1507,1511,1607,1703,1709,1803,1809,1903,1909,20H1,20H2,21H1,21H2,11
-set /a dV=14
+set VERSIONS=1507,1511,1607,1703,1709,1803,1809,1903,1909,20H1,20H2,21H1,21H2,22H2,11,11_22H2
+set /a dV=16
 
 ::# MCT Preset choice dialog items and default-index [Select in MCT]
 set PRESETS=^&Auto Upgrade,Auto ^&ISO,Auto ^&USB,^&Select,MCT ^&Defaults
@@ -66,7 +66,7 @@ set "OS_ARCH=x64" & if "%PROCESSOR_ARCHITECTURE:~-2%" equ "86" if not defined PR
 
 ::# parse MCT choice from script name or commandline - accepts both formats: 1909 or 19H2 etc.
 for %%V in (1.1507 2.1511 3.1607 4.1703 5.1709 6.1803 7.1809 8.1903 8.19H1 9.1909 9.19H2 10.2004 10.20H1 11.2009 11.20H2 12.2104
- 12.21H1 13.2109 13.21H2 14.2110 14.11) do for %%s in (%MCT% %~n0 %*) do if /i %%~xV equ .%%~s set "MCT=%%~nV" & set "VID=%%~s"
+ 12.21H1 13.2109 13.21H2 14.2110 14.11 15.2209 15.11) do for %%s in (%MCT% %~n0 %*) do if /i %%~xV equ .%%~s set "MCT=%%~nV" & set "VID=%%~s"
 if defined MCT if not defined VID set "MCT="
 
 ::# parse AUTO from script name or commandline - starts unattended upgrade / in-place repair / cross-edition
@@ -120,7 +120,7 @@ if not defined VID (set VID=%OS_VID%)
 (set MEDIA_EDITION=%MEDIA_EDITION:IoTEnterpriseS=Enterprise%)
 
 ::# get previous GUI selection if self elevated and skip to choice
-for %%s in (%*) do for %%P in (1 2 3 4) do if %%~ns gtr 0 if %%~ns lss 15 if %%~xs. equ .%%P. set /a PRE=%%P & set /a MCT=%%~ns
+for %%s in (%*) do for %%P in (1 2 3 4) do if %%~ns gtr 0 if %%~ns lss 16 if %%~xs. equ .%%P. set /a PRE=%%P & set /a MCT=%%~ns
 
 ::# write auto media preset hint
 %<%:f0 " Detected Media "%>>% & if defined MCT %<%:5f " %VID% "%>>%
@@ -142,12 +142,24 @@ if %MCT%0 gtr 1 if %PRE%0 lss 1 call :choices PRE "%PRESETS%"  %dP% "MCT Preset"
 if %MCT%0 gtr 1 if %PRE%0 lss 1 goto choice-0 = cancel
 goto choice-%MCT%
 
-:choice-14
+:choice-16
+set "VER=22621" & set "VID=22H2" & set "CB=22621.525.220925-0207.ni_release_svc_refresh" & set "CT=2022/09/" & set "CC=2.0"
+set "CAB=https://download.microsoft.com/download/a/e/5/ae50fa4c-e37b-4ef1-bf6b-60a0e4382d08/products_Win11_20220926.cab"
+set "EXE=https://software-static.download.prss.microsoft.com/dbazure/988969d5-f34g-4e03-ac9d-1f9786c66749/mediacreationtool.exe"
+goto process ::# windows 11 22H2
+
+:choice-15
 set "VER=22000" & set "VID=11" & set "CB=22000.318.211104-1236.co_release_svc_refresh" & set "CT=2021/11/" & set "CC=2.0"
 set "CAB=https://download.microsoft.com/download/1/b/4/1b4e06e2-767a-4c9a-9899-230fe94ba530/products_Win11_20211115.cab"
 set "EXE=https://software-download.microsoft.com/download/pr/888969d5-f34g-4e03-ac9d-1f9786c69161/MediaCreationToolW11.exe"
 goto process ::# windows 11 : usability and ui downgrade, and even more ChrEdge bloat (but somewhat snappier multitasking)
 
+:choice-14
+set "VER=19045" & set "VID=22H2" & set "CB=19045.2006.220908-0225.22h2_release_svc_refresh" & set "CT=2022/09/" & set "CC=1.4.1"
+set "CAB=https://download.microsoft.com/download/e/6/c/e6c6ef82-8b05-4c0f-9852-d2b86129de29/products_Win10_20220916.cab"
+set "EXE=https://download.microsoft.com/download/9/e/a/9eac306f-d134-4609-9c58-35d1638c2363/MediaCreationTool22H2.exe"
+goto process ::# refreshed 19041 base with integrated 22H2 enablement package - current
+
 :choice-13
 set "VER=19044" & set "VID=21H2" & set "CB=19044.1288.211006-0501.21h2_release_svc_refresh" & set "CT=2021/11/" & set "CC=1.4.1"
 set "CAB=https://download.microsoft.com/download/3/9/6/396ae429-afb2-49da-81d8-c16c6782d082/products_Win10_20211115.cab"
@@ -341,7 +353,10 @@ if defined MEDIA for %%s in (%MEDIA_KEY%) do (if not defined KEY set KEY=%%s)
 if %VER% geq 22000 (set MEDIA_ARCH=x64& if defined ARCH set ARCH=x64)
 
 ::# windows 11 vs 10 label quirks - guess I should not have combined them, but then again, 11 is 10 with a ui downgrade ;)
-if %VER% geq 22000 (set X=11& set VIS=21H2) else (set X=10& set VIS=%VID%)
+if %VER% geq 22000 (set X=11& set VIS=22H2) else (set X=10& set VIS=%VID%)
+
+::# windows 11 22h2
+if %VER% geq 22621 (set X=11& set VIS=22H2)
 
 ::# refresh screen
 cls & <"%~f0" (set /p _=&for /l %%s in (1,1,20) do set _=& set/p _=& call echo;%%_%%)