@echo off

::------------------------------------------------------------------------------
:: MSMG 工具箱 v10.2
:: 版权所有 (c) 2013-2020 MSMG。保留所有权利。
::------------------------------------------------------------------------------
::
:: 贡  献  者： CREDITS.TXT
:: 许      可： LICENSE.TXT
:: 第三方许可： <Bin\LICENSES>
::
::-------------------------------------------------------------------------------------------

color 1f
title MSMG 工具箱 v10.2

reg add "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v "ScreenBufferSize" /t REG_DWORD /d "0x23290050" /f >nul
reg add "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v "WindowSize" /t REG_DWORD /d "0x190050" /f >nul

setlocal EnableExtensions
setlocal EnableDelayedExpansion

:: 设置工具箱环境路径变量
set "Bin=%~dp0Bin"
set "Custom=%~dp0Custom"
set "Drivers=%~dp0Drivers"
set "DVD=%~dp0DVD"
set "ISO=%~dp0ISO"
set "Logs=%~dp0Logs"
set "Mount=%~dp0Mount"
set "Packs=%~dp0Packs"
set "ROOT=%~dp0"
set "Temp=%~dp0Temp"
set "Updates=%~dp0Updates"
set "WHD=%~dp0WHD"

:: 设置主机操作系统版本、体系结构和语言变量
for /f "tokens=4-5 delims=. " %%i in ('ver 2^>nul') do set "HostVersion=%%i.%%j"
If exist "%WinDir%\SysWOW64" set "HostArchitecture=x64"
If not exist "%WinDir%\SysWOW64" set "HostArchitecture=x86"
set HostLanguage=

:: 设置 WADK 工具环境路径变量
if "%HostVersion%" equ "6.1" set "DISM=%Bin%\%HostArchitecture%\DISM81\Dism.exe"
if "%HostVersion%" neq "6.1" set "DISM=%Bin%\%HostArchitecture%\DISM10\Dism.exe"
set "DismScratch=%Temp%\DISM"
set "DismFormat=/English /ScratchDir:%DismScratch% /LogPath:%Logs%\Dism.txt /LogLevel:3 /NoRestart"
set "Imagex=%Bin%\%HostArchitecture%\imagex.exe"
set "Oscdimg=%Bin%\%HostArchitecture%\oscdimg.exe"
set "Dvdburn=%Bin%\dvdburn.exe"
set "WimConfigFile=%Bin%\wimscript.ini"

:: 设置源操作系统变量
set SelectedSourceOS=
set "BootWim=%DVD%\sources\boot.wim"
set "InstallWim=%DVD%\sources\install.wim"
set "InstallEsd=%DVD%\sources\install.esd"
set "WinReWim=Windows\System32\Recovery\winre.wim"
set "BootMount=%Mount%\Boot"
set "InstallMount=%Mount%\Install"
set "WinReMount=%Mount%\WinRE"

:: 设置源映像信息变量
set ImageCount=
set ImageIndexNo=
set ImageArchitecture=
set ImageName=
set ImageDescription=
set ImageFlag=
set ImageEdition=
set ImageInstallationType=
set ImageDefaultLanguage=
set ImageMajorVersion=
set ImageMinorVersion=
set ImageBuild=
set ImageVersion=
set ImageServicePackBuild=
set PackageServicePackBuild=
set ImageServicePackLevel=
set ImageSize=

:: 设置工具箱的控制标识变量
set IsSourceSelected=No
set IsBootImageSelected=No
set IsRecoveryImageSelected=No
set IsRecoveryImageModified=
set IsDialogsEnabled=Yes
set IsLogsEnabled=Yes
set IsImageRegistryLoaded=No
set IsW7SP1CRUSelected=

set "PreActTokens=%Custom%\ActivationTokens"
set "CustomFiles=%Custom%\Files"
set "CustomRecoveryImage=%Custom%\RecoveryImage"
set "CustomRegistry=%Custom%\Registry"
set "CustomTerminalServer=%Custom%\TerminalServer"
set "CustomUxTheme=%Custom%\UxTheme"

:: 设置工具箱的包环境路径变量
set "Apps=%Packs%\Apps"
set "Braille=%Packs%\Braille"
set "DaRT=%Packs%\DaRT"
set "Dedup=%Packs%\Dedup"
set "DirectX9c=%Packs%\DirectX9c"
set "EdgeClassic=%Packs%\EdgeBrowser"
set "EdgeChromium=%Packs%\EdgeChromium"
set "Games=%Packs%\Games"
set "IE11=%Packs%\IE11"
set "LanguagePacks=%Packs%\LanguagePacks"
set "MediaFeaturePack=%Packs%\MediaFeaturePack"
set "MMRC=%Packs%\MultimediaRestrictedCodecs"
set "NetFx35=%Packs%\NetFX35"
set "NetFx462=%Packs%\NetFX462"
set "NetFx48=%Packs%\NetFX48"
set "OfficeUWP=%Packs%\OfficeUWP"
set "OpenSSH=%Packs%\OpenSSH"
set "PortableDevices=%Packs%\PortableDevices"
set "PowerShell7=%Packs%\PowerShell7"
set "RDP81=%Packs%\RDP81"
set "RSAT=%Packs%\RSAT"
set "Sidebar=%Packs%\Sidebar"
set "Skins=%Packs%\Skins"
set "SystemRestore=%Packs%\SystemRestore"
set "ThinPC=%Packs%\ThinPC"
set "UAP=%Packs%\UAP"
set "VCRuntime=%Packs%\VCRuntime"
set "Win32Calc=%Packs%\Win32Calc"
set "WinToGo=%Packs%\WinToGo"
set "WMF=%Packs%\WMF"
set "WSL=%Packs%\WSL"

:: 设置工具箱的依赖工具环境路径变量
set "Lists=%Bin%\Lists"
set "Patches=%Bin%\Patches"
set "ResourceHacker=%Bin%\ResourceHacker.exe"
set "ToolKitHelper=%Bin%\ToolKitHelper.exe"
set "W10EsdDecrypter=%Bin%\Dism++CUI.exe /ESDFile"
set "W81EsdDecrypter=%Bin%\esddecrypt.exe"
set "WimlibImagex=%Bin%\%HostArchitecture%\wimlib-imagex.exe"
set "XCopy=xcopy.exe /E /I /H /R /Y /J"
set "XMLs=%Bin%\XMLs"
set "W7ESUFix=%Bin%\Patches\W7ESUFix"
set "W10CUFix=%Bin%\Patches\W10CUFix"
set "WMCGActTokens=%Bin%\Patches\WMCGActTokens.tpk"
set "Zip=%Bin%\%HostArchitecture%\7z.exe"

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 最终用户许可协议
::-------------------------------------------------------------------------------------------
cls

echo.===============================================================================
echo.##################### MSMG 工具箱 - 最终用户许可协议 ##########################
echo.===============================================================================
echo.
echo.
echo. MSMG 工具箱基本上是一个集维护、自定义定制、添加或删除功能和组件、启用或者禁
echo. 用 Windows 操作系统中的功能的工具。
echo.
echo.
echo. MSMG 工具箱仅限用于已通过许可的 Microsoft Windows 操作系统。
echo.
echo.
echo. 此 MSMG 工具箱“按原样”提供，并且不作任何明示或暗示性的保证。在任何情况之下，
echo. 作者均不会对因为使用此脚本工具而导致可能的任何破坏承担责任。
echo.
echo.
echo. MSMG 工具箱将会使用各类第三方工具来完成其中的一部分任务。
echo.
echo.
echo. MSMG 工具箱、Windows 均为其各自公司或作者的注册商标。
echo.
echo.
echo.                                                仅用于测试。简体中文 v10.2 beta
echo.===============================================================================
choice /C AR /N /M "########################[ 按‘A’同意 / 按‘R’拒绝 ]#########################"
if errorlevel 2 (
	reg delete "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /f >nul

	color 00
	endlocal EnableExtensions
	endlocal EnableDelayedExpansion

	exit
)

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 启动功能
::-------------------------------------------------------------------------------------------
cls

echo.
echo.正在执行工具箱预清理操作，请稍候……
call :Cleanup >nul
cls
echo.===============================================================================
echo.                               MSMG 工具箱 - 启动
echo.===============================================================================
echo.
echo.正在读取主机操作系统信息……
for /f "tokens=6 delims= " %%a in ('DISM /Online /English /Get-Intl ^| findstr /i /C:"Default system UI language"') do (set HostLanguage=%%a)
echo.
if "%HostArchitecture%" equ "x86" (
	if "%HostVersion%" equ "6.1" echo. - Microsoft Windows 7 ^(%HostArchitecture%^) [%HostLanguage%]
	if "%HostVersion%" equ "6.3" echo. - Microsoft Windows 8.1 ^(%HostArchitecture%^) [%HostLanguage%]
	if "%HostVersion%" equ "10.0" echo. - Microsoft Windows 10 ^(%HostArchitecture%^) [%HostLanguage%]
)

if "%HostArchitecture%" equ "x64" (
	if "%HostVersion%" equ "6.1" echo. - Microsoft Windows 7 / Server 2008 R2 ^(%HostArchitecture%^) [%HostLanguage%]
	if "%HostVersion%" equ "6.3" echo. - Microsoft Windows 8.1 / Server 2012 R2 ^(%HostArchitecture%^) [%HostLanguage%]
	if "%HostVersion%" equ "10.0" echo. - Microsoft Windows 10 / Server 2016/2019 ^(%HostArchitecture%^) [%HostLanguage%]
)

:: 设置 DOS 字符代码页
if "%HostLanguage%" equ "en-GB" chcp 437 >nul
if "%HostLanguage%" equ "en-US" chcp 437 >nul
if "%HostLanguage%" equ "zh-CN" chcp 936 >nul

echo.
echo.正在设置工具箱和 WADK 工具环境路径变量……
echo.
echo.DISM.exe           =  %DISM%
call :CreateFolder "%DismScratch%"
set "DISM=%DISM% %DismFormat%"
echo.Imagex.exe         =  %Imagex%
echo.Oscdimg.exe        =  %Oscdimg%
echo.Dvdburn.exe        =  %Dvdburn%
echo.7zip.exe           =  %Zip%
echo.Dism++CUI.exe      =  %W10EsdDecrypter%
echo.EsdDecrypt.exe     =  %W81EsdDecrypter%
echo.ToolKitHelper.exe  =  %ToolKitHelper%
echo.ResourceHacker.exe =  %ResourceHacker%
echo.WimlibImagex.exe   =  %WimlibImagex%
echo.
echo.===============================================================================
echo.
echo 请按 ENTER 键继续执行……
pause >nul
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 主菜单
::-------------------------------------------------------------------------------------------
:MainMenu

cls
echo.===============================================================================
echo.                          MSMG 工具箱 - 主  菜  单
echo.===============================================================================
echo.
echo.                             [1]   源  文  件
echo.
echo.                             [2]   转      换
echo.
echo.                             [3]   集      成
echo.
echo.                             [4]   移      除
echo.
echo.                             [5]   自定义定制
echo.
echo.                             [6]   应      用
echo.
echo.                             [7]   目      标
echo.
echo.                             [8]   工      具
echo.
echo.                             [X]   退      出
echo.
echo.===============================================================================
choice /C:12345678X /N /M "请输入你的选项 ："
if errorlevel 9 goto :Quit
if errorlevel 8 goto :ToolsMenu
if errorlevel 7 goto :TargetMenu
if errorlevel 6 goto :ApplyMenu
if errorlevel 5 goto :CustomizeMenu
if errorlevel 4 goto :RemoveMenu
if errorlevel 3 goto :IntegrateMenu
if errorlevel 2 goto :ConvertMenu
if errorlevel 1 goto :SourceMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 选择源文件菜单
::-------------------------------------------------------------------------------------------
:SourceMenu

cls
echo.===============================================================================
echo.                          MSMG 工具箱 - 源文件菜单
echo.===============================================================================
echo.

:: 检查源操作系统是否已选择
if "%IsSourceSelected%" equ "Yes" (
	echo.源操作系统已被选择……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查是否加载了映像注册表
if "%IsImageRegistryLoaded%" equ "Yes" (
	echo.已加载源操作系统映像注册表，请使用工具 -^> 选项卸载……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

echo.  [1]   从 ^<DVD^> 文件夹中选择源文件
echo.
echo.  [2]   从 DVD 驱动器中复制源文件
echo.
echo.  [3]   从 DVD ISO 镜像中解压源文件
echo.
echo.  [4]   从 OEM IMG 映像中解压源文件
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:1234X /N /M "请输入你的选项 ："
if errorlevel 5 goto :MainMenu
if errorlevel 4 goto :SelectSourceIMG
if errorlevel 3 goto :SelectSourceISO
if errorlevel 2 goto :SelectSourceCopy
if errorlevel 1 goto :SelectSourceDVD
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 源映像/版本转换菜单
::-------------------------------------------------------------------------------------------
:ConvertMenu

cls
echo.===============================================================================
echo.                        MSMG 工具箱 - 源映像转换菜单
echo.===============================================================================
echo.

:: 检查源操作系统是否已选择
if "%IsSourceSelected%" equ "Yes" (
	echo.当源操作系统被选择时，无法使用此功能……
	echo.
	echo.===============================================================================
	echo.
	pause
	
	goto :Mainmenu
)

echo.  [1]   转换应用商店 ESD 映像为 WIM 映像
echo.
echo.  [2]   转换 ESD 映像为 WIM 映像
echo.
echo.  [3]   转换 MCT 映像为 WIM 映像
echo.
echo.  [4]   转换 WIM 映像为 ESD 映像
echo.
echo.  [X]   返回
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.        
echo.===============================================================================
echo.
choice /C:1234X /N /M "请输入你的选项 ："
if errorlevel 5 goto :MainMenu
if errorlevel 4 goto :ConvertWim2Esd
if errorlevel 3 goto :ConvertMCT2Wim
if errorlevel 2 goto :ConvertEsd2Wim
if errorlevel 1 goto :ConvertStoreEsd2Wim
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 集成菜单
::-------------------------------------------------------------------------------------------
:IntegrateMenu

cls
echo.===============================================================================
echo.                           MSMG 工具箱 - 集成菜单
echo.===============================================================================
echo.
:: 检查源操作系统是否已选择
if "%IsSourceSelected%" equ "No" (
	echo.尚未选择源操作系统，请从“源文件”菜单中选择……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查是否加载了映像注册表
if "%IsImageRegistryLoaded%" equ "Yes" (
	echo.已加载源操作系统映像注册表，请使用工具 -^> 选项卸载……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

echo.  [1]   Windows 语言包
echo.
echo.  [2]   Windows 驱动
echo.
echo.  [3]   Windows 功能
echo.
echo.  [4]   Windows 更新
echo.
echo.  [5]   Windows 自定义功能
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:12345X /N /M "请输入你的选项 ："
if errorlevel 6 goto :MainMenu
if errorlevel 5 goto :IntCustomFeatures
if errorlevel 4 goto :IntUpdatesMenu
if errorlevel 3 goto :IntFeatures
if errorlevel 2 goto :IntDrivers
if errorlevel 1 goto :IntLanguagePacks
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 集成 Windows 功能菜单
::-------------------------------------------------------------------------------------------
:IntFeatures

cls
echo.===============================================================================
echo.                    MSMG 工具箱 - 集成 Windows 功能菜单
echo.===============================================================================

:: 检查所选择的源操作系统是否是 Windows 7 客户端版本
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" (
	echo.
	echo.  [A]   Microsoft .NET Framework 4.8
	echo.  [B]   Microsoft Internet Explorer 11
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   远程桌面协议 ^(RDP^) 8.0 和 8.1
	echo.  [E]   Windows 媒体功能包
	echo.  [F]   Windows Management Framework ^(WMF^) 5.1
	echo.  [G]   Windows PowerShell 7.0
	echo.  [H]   远程服务器管理工具 ^(RSAT^)
	echo.  [I]   Microsoft DaRT 7.0 工具集
	echo.  [J]   Microsoft DirectX 9.0c
	echo.  [K]   Microsoft 游戏
	echo.  [L]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLX /N /M "请输入你的选项 ："
	if errorlevel 13 goto :IntegrateMenu
	if errorlevel 12 goto :IntVCRuntime
	if errorlevel 11 goto :IntGames
	if errorlevel 10  goto :IntDirectX9c
	if errorlevel 9  goto :IntDaRT
	if errorlevel 8  goto :IntRSAT
	if errorlevel 7  goto :IntPowerShell7
	if errorlevel 6  goto :IntWMF
	if errorlevel 5  goto :IntMediaFeaturePack
	if errorlevel 4  goto :IntRDP81
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntIE11
	if errorlevel 1  goto :IntNetFX48
)

:: 检查所选择的源操作系统是否是 Windows 7 Embedded 版本
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Embedded" (
	echo.
	echo.  [A]   Microsoft .NET Framework 4.8
	echo.  [B]   Microsoft Internet Explorer 11
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   远程桌面协议 ^(RDP^) 8.0 和 8.1
	echo.  [E]   Windows Management Framework ^(WMF^) 5.1
	echo.  [F]   Windows PowerShell 7.0
	echo.  [G]   Windows Thin PC 附加功能
	echo.  [H]   Microsoft DaRT 7.0 工具集
	echo.  [I]   Microsoft DirectX 9.0c
	echo.  [J]   Microsoft 游戏
	echo.  [K]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKX /N /M "请输入你的选项 ："
	if errorlevel 12 goto :IntegrateMenu
	if errorlevel 11 goto :IntVCRuntime
	if errorlevel 10 goto :IntGames
	if errorlevel 9  goto :IntDirectX9c
	if errorlevel 8  goto :IntDaRT
	if errorlevel 7  goto :IntThinPcPkgs
	if errorlevel 6  goto :IntPowerShell7
	if errorlevel 5  goto :IntWMF
	if errorlevel 4  goto :IntRDP81
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntIE11
	if errorlevel 1  goto :IntNetFX48
)

:: 检查所选择的源操作系统是否是 Windows Server 2008 R2 Core 版本
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Server Core" (
	echo.
	echo.  [A]   Microsoft .NET Framework 4.8
	echo.  [B]   Microsoft Internet Explorer 11
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   远程桌面协议 ^(RDP^) 8.0 和 8.1
	echo.  [E]   Windows Management Framework ^(WMF^) 5.1
	echo.  [F]   Windows PowerShell 7.0
	echo.  [G]   Microsoft DaRT 7.0 工具集
	echo.  [H]   Microsoft DirectX 9.0c
	echo.  [I]   Microsoft 游戏
	echo.  [J]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJX /N /M "请输入你的选项 ："
	if errorlevel 11 goto :IntegrateMenu
	if errorlevel 10 goto :IntVCRuntime
	if errorlevel 9  goto :IntGames
	if errorlevel 8  goto :IntDirectX9c
	if errorlevel 7  goto :IntDaRT
	if errorlevel 6  goto :IntPowerShell7
	if errorlevel 5  goto :IntWMF
	if errorlevel 4  goto :IntRDP81
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntIE11
	if errorlevel 1  goto :IntNetFX48
)

:: 检查所选择的源操作系统是否是 Windows Server 2008 R2
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Server" (
	echo.
	echo.  [A]   Microsoft .NET Framework 4.8
	echo.  [B]   Microsoft Internet Explorer 11
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   远程桌面协议 ^(RDP^) 8.0 和 8.1
	echo.  [E]   Windows Management Framework ^(WMF^) 5.1
	echo.  [F]   Windows PowerShell 7.0
	echo.  [G]   Windows 系统恢复
	echo.  [H]   Microsoft DaRT 7.0 工具集
	echo.  [I]   Microsoft DirectX 9.0c
	echo.  [J]   Microsoft 游戏
	echo.  [K]   Windows 边栏
	echo.  [L]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLX /N /M "请输入你的选项 ："
	if errorlevel 13 goto :IntegrateMenu
	if errorlevel 12 goto :IntVCRuntime
	if errorlevel 11 goto :IntSidebar
	if errorlevel 10 goto :IntGames
	if errorlevel 9  goto :IntDirectX9c
	if errorlevel 8  goto :IntDaRT
	if errorlevel 7  goto :IntSystemRestore
	if errorlevel 6  goto :IntPowerShell7
	if errorlevel 5  goto :IntWMF
	if errorlevel 4  goto :IntRDP81
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntIE11
	if errorlevel 1  goto :IntNetFX48
)

:: 检查所选择的源操作系统是否是 Windows 8.1 RT（ARM）
if "%SelectedSourceOS%" equ "w81" if "%ImageArchitecture%" equ "arm" (
	echo.
	echo.  [1]   Microsoft .NET Framework 4.8
	echo.
	echo.  [2]   Microsoft 默认 Metro 应用
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :IntegrateMenu
	if errorlevel 2 goto :IntMetroApps
	if errorlevel 1 goto :IntNetFX48
)

:: 检查所选择的源操作系统是否是 Windows 8.1 32-位
if "%SelectedSourceOS%" equ "w81" if "%ImageArchitecture%" equ "x86" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Windows To Go 工作区
	echo.  [E]   Windows 媒体功能包
	echo.  [F]   Microsoft 默认 Metro 应用
	echo.  [G]   Windows Management Framework ^(WMF^) 5.1
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft DaRT 8.1 工具集
	echo.  [K]   Microsoft DirectX 9.0c
	echo.  [L]   Microsoft 游戏
	echo.  [M]   Windows 边栏
	echo.  [N]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNX /N /M "请输入你的选项 ："
	if errorlevel 15 goto :IntegrateMenu
	if errorlevel 14 goto :IntVCRuntime
	if errorlevel 13 goto :IntSidebar
	if errorlevel 12 goto :IntGames
	if errorlevel 11 goto :IntDirectX9c
	if errorlevel 10 goto :IntDaRT
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntWMF
	if errorlevel 6  goto :IntMetroApps
	if errorlevel 5  goto :IntMediaFeaturePack
	if errorlevel 4  goto :IntWinToGo
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 8.1 64-位非服务器版
if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" neq "Server" if "%ImageArchitecture%" equ "x64" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Windows 重复数据删除
	echo.  [E]   Windows To Go 工作区
	echo.  [F]   Windows 媒体功能包
	echo.  [G]   Microsoft 默认 Metro 应用
	echo.  [H]   Windows Management Framework ^(WMF^) 5.1
	echo.  [I]   Windows PowerShell 7.0
	echo.  [J]   远程服务器管理工具 ^(RSAT^)
	echo.  [K]   Microsoft DaRT 8.1 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntRSAT
	if errorlevel 9  goto :IntPowerShell7
	if errorlevel 8  goto :IntWMF
	if errorlevel 7  goto :IntMetroApps
	if errorlevel 6  goto :IntMediaFeaturePack
	if errorlevel 5  goto :IntWinToGo
	if errorlevel 4  goto :IntDedup
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server 2012 R2 Core 版本
if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType%" equ "Server Core" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Windows Management Framework ^(WMF^) 5.1
	echo.  [D]   Windows PowerShell 7.0
	echo.  [E]   Microsoft DaRT 8.1 工具集
	echo.  [F]   Microsoft DirectX 9.0c
	echo.  [G]   Microsoft 游戏
	echo.  [H]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHX /N /M "请输入你的选项 ："
	if errorlevel 9 goto :IntegrateMenu
	if errorlevel 8 goto :IntVCRuntime
	if errorlevel 7 goto :IntGames
	if errorlevel 6 goto :IntDirectX9c
	if errorlevel 5 goto :IntDaRT
	if errorlevel 4 goto :IntPowerShell7
	if errorlevel 3 goto :IntWMF
	if errorlevel 2 goto :IntNetFX48
	if errorlevel 1 goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server 2012 R2
if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType%" equ "Server" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft 默认 Metro 应用
	echo.  [E]   Windows Management Framework ^(WMF^) 5.1
	echo.  [F]   Windows PowerShell 7.0
	echo.  [G]   Microsoft DaRT 8.1 工具集
	echo.  [H]   Microsoft DirectX 9.0c
	echo.  [I]   Microsoft 游戏
	echo.  [J]   Windows 边栏
	echo.  [K]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKX /N /M "请输入你的选项 ："
	if errorlevel 12 goto :IntegrateMenu
	if errorlevel 11 goto :IntVCRuntime
	if errorlevel 10 goto :IntSidebar
	if errorlevel 9  goto :IntGames
	if errorlevel 8  goto :IntDirectX9c
	if errorlevel 7  goto :IntDaRT
	if errorlevel 6  goto :IntPowerShell7
	if errorlevel 5  goto :IntWMF
	if errorlevel 4  goto :IntMetroApps
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35  	
)

:: 检查所选择的源操作系统是否是 Windows 10 v1507 客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10240" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.6.2
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Microsoft Win32 计算器
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏 ^| Depends on: Windows 邮件应用
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntWin32Calc
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX462
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1511 32-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10586" if "%ImageArchitecture%" equ "x86" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.6.2
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows To Go 工作区
	echo.  [F]   Windows 媒体功能包
	echo.  [G]   Windows PowerShell 7.0
	echo.  [H]   远程服务器管理工具 ^(RSAT^)
	echo.  [I]   Microsoft 默认 Metro 应用
	echo.  [J]   Microsoft DaRT 10.0 工具集
	echo.  [K]   Microsoft DirectX 9.0c
	echo.  [L]   Microsoft 游戏
	echo.  [M]   Windows 边栏
	echo.  [N]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNX /N /M "请输入你的选项 ："
	if errorlevel 15 goto :IntegrateMenu
	if errorlevel 14 goto :IntVCRuntime
	if errorlevel 13 goto :IntSidebar
	if errorlevel 12 goto :IntGames
	if errorlevel 11 goto :IntDirectX9c
	if errorlevel 10 goto :IntDaRT
	if errorlevel 9  goto :IntMetroApps
	if errorlevel 8  goto :IntRSAT
	if errorlevel 7  goto :IntPowerShell7
	if errorlevel 6  goto :IntMediaFeaturePack
	if errorlevel 5  goto :IntWinToGo
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX462
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1607 32-位客户端版本企业版 LTSB 2016
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x86" if "%ImageFlag%" equ "EnterpriseS" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Microsoft Win32 计算器
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntWin32Calc
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1607 32-位客户端版本企业版 N LTSB 2016
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x86" if "%ImageFlag%" equ "EnterpriseSN" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Microsoft Win32 计算器
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntWin32Calc
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1607 32-位客户端版本非企业版（N）LTSB 2016
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x86" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows To Go 工作区
	echo.  [F]   Windows 媒体功能包
	echo.  [G]   Windows PowerShell 7.0
	echo.  [H]   远程服务器管理工具 ^(RSAT^)
	echo.  [I]   Microsoft 默认 Metro 应用
	echo.  [J]   Microsoft DaRT 10.0 工具集
	echo.  [K]   Microsoft DirectX 9.0c
	echo.  [L]   Microsoft 游戏
	echo.  [M]   Windows 边栏
	echo.  [N]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNX /N /M "请输入你的选项 ："
	if errorlevel 15 goto :IntegrateMenu
	if errorlevel 14 goto :IntVCRuntime
	if errorlevel 13 goto :IntSidebar
	if errorlevel 12 goto :IntGames
	if errorlevel 11 goto :IntDirectX9c
	if errorlevel 10 goto :IntDaRT
	if errorlevel 9  goto :IntMetroApps
	if errorlevel 8  goto :IntRSAT
	if errorlevel 7  goto :IntPowerShell7
	if errorlevel 6  goto :IntMediaFeaturePack
	if errorlevel 5  goto :IntWinToGo
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1703 32-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "15063" if "%ImageArchitecture%" equ "x86" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 盲文辅助功能
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntBraille
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1709 32-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "16299" if "%ImageArchitecture%" equ "x86" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 盲文辅助功能
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [K]   Microsoft 默认 Metro 应用
	echo.  [L]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [N]   Microsoft 游戏
	echo.  [O]   Windows 边栏
	echo.  [P]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPX /N /M "请输入你的选项 ："
	if errorlevel 17 goto :IntegrateMenu
	if errorlevel 16 goto :IntVCRuntime
	if errorlevel 15 goto :IntSidebar
	if errorlevel 14 goto :IntGames
	if errorlevel 13 goto :IntDirectX9c
	if errorlevel 12  goto :IntDaRT
	if errorlevel 11 goto :IntMetroApps
	if errorlevel 10 goto :IntOpenSSH
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntBraille
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1803 32-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17134" if "%ImageArchitecture%" equ "x86" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 盲文辅助功能
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [K]   Microsoft 默认 Metro 应用
	echo.  [L]   Microsoft Office 桌面 UWP 应用
	echo.  [M]   Microsoft DaRT 10.0 工具集
	echo.  [N]   Microsoft DirectX 9.0c
	echo.  [O]   Microsoft 游戏
	echo.  [P]   Windows 边栏
	echo.  [Q]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQX /N /M "请输入你的选项 ："
	if errorlevel 18 goto :IntegrateMenu
	if errorlevel 17 goto :IntVCRuntime
	if errorlevel 16 goto :IntSidebar
	if errorlevel 15 goto :IntGames
	if errorlevel 14 goto :IntDirectX9c
	if errorlevel 13 goto :IntDaRT
	if errorlevel 12 goto :IntOfficeUWPApps
	if errorlevel 11 goto :IntMetroApps
	if errorlevel 10 goto :IntOpenSSH
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntBraille
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1809 32-位客户端版本企业版 LTSC 2019
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x86" if "%ImageFlag%" equ "EnterpriseS" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Microsoft Win32 计算器
	echo.  [F]   Windows 盲文辅助功能
	echo.  [G]   Windows To Go 工作区
	echo.  [H]   Windows 媒体功能包
	echo.  [I]   Windows 便携设备	
	echo.  [J]   Windows PowerShell 7.0
	echo.  [K]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [L]   Microsoft 默认 Metro 应用
	echo.  [M]   Microsoft Office 桌面 UWP 应用
	echo.  [N]   Microsoft DaRT 10.0 工具集
	echo.  [O]   Microsoft DirectX 9.0c
	echo.  [P]   Microsoft 游戏
	echo.  [Q]   Windows 边栏
	echo.  [R]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRX /N /M "请输入你的选项 ："
	if errorlevel 19 goto :IntegrateMenu
	if errorlevel 18 goto :IntVCRuntime
	if errorlevel 17 goto :IntSidebar
	if errorlevel 16 goto :IntGames
	if errorlevel 15 goto :IntDirectX9c
	if errorlevel 14 goto :IntDaRT
	if errorlevel 13 goto :IntOfficeUWPApps
	if errorlevel 12 goto :IntMetroApps
	if errorlevel 11 goto :IntOpenSSH
	if errorlevel 10 goto :IntPowerShell7
	if errorlevel 9  goto :IntPortableDevices
	if errorlevel 8  goto :IntMediaFeaturePack
	if errorlevel 7  goto :IntWinToGo
	if errorlevel 6  goto :IntBraille
	if errorlevel 5  goto :IntEdgeChromium
	if errorlevel 4  goto :IntEdgeClassic
	if errorlevel 3  goto :IntWin32Calc
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1809 32-位客户端版本企业版 N LTSC 2019
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ 17763 if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x86" if "%ImageFlag%" equ "EnterpriseSN" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Microsoft Win32 计算器
	echo.  [F]   Windows 盲文辅助功能
	echo.  [G]   Windows To Go 工作区
	echo.  [H]   Windows 媒体功能包
	echo.  [I]   Windows 便携设备	
	echo.  [J]   Windows PowerShell 7.0
	echo.  [K]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [L]   Microsoft 默认 Metro 应用
	echo.  [M]   Microsoft Office 桌面 UWP 应用
	echo.  [N]   Microsoft DaRT 10.0 工具集
	echo.  [O]   Microsoft DirectX 9.0c
	echo.  [P]   Microsoft 游戏
	echo.  [Q]   Windows 边栏
	echo.  [R]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRX /N /M "请输入你的选项 ："
	if errorlevel 19 goto :IntegrateMenu
	if errorlevel 18 goto :IntVCRuntime
	if errorlevel 17 goto :IntSidebar
	if errorlevel 16 goto :IntGames
	if errorlevel 15 goto :IntDirectX9c
	if errorlevel 14 goto :IntDaRT
	if errorlevel 13 goto :IntOfficeUWPApps
	if errorlevel 12 goto :IntMetroApps
	if errorlevel 11 goto :IntOpenSSH
	if errorlevel 10 goto :IntPowerShell7
	if errorlevel 9  goto :IntPortableDevices
	if errorlevel 8  goto :IntMediaFeaturePack
	if errorlevel 7  goto :IntWinToGo
	if errorlevel 6  goto :IntBraille
	if errorlevel 5  goto :IntEdgeChromium
	if errorlevel 4  goto :IntEdgeClassic
	if errorlevel 3  goto :IntWin32Calc
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1809 32-位客户端版本非企业版（N）LTSC 2019
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x86" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 盲文辅助功能
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows 便携设备
	echo.  [I]   Windows PowerShell 7.0
	echo.  [J]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [K]   Microsoft 默认 Metro 应用
	echo.  [L]   Microsoft Office 桌面 UWP 应用
	echo.  [M]   Microsoft DaRT 10.0 工具集
	echo.  [N]   Microsoft DirectX 9.0c
	echo.  [O]   Microsoft 游戏
	echo.  [P]   Windows 边栏
	echo.  [Q]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQX /N /M "请输入你的选项 ："
	if errorlevel 18 goto :IntegrateMenu
	if errorlevel 17 goto :IntVCRuntime
	if errorlevel 16 goto :IntSidebar
	if errorlevel 15 goto :IntGames
	if errorlevel 14 goto :IntDirectX9c
	if errorlevel 13 goto :IntDaRT
	if errorlevel 12 goto :IntOfficeUWPApps
	if errorlevel 11 goto :IntMetroApps
	if errorlevel 10 goto :IntOpenSSH
	if errorlevel 9  goto :IntPowerShell7
	if errorlevel 8  goto :IntPortableDevices
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntBraille
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1903/v1909 32-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageBuild%" leq "18363" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x86" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft Edge Chromium 浏览器
	echo.  [C]   Microsoft Win32 计算器
	echo.  [D]   Windows 盲文辅助功能
	echo.  [E]   Windows To Go 工作区
	echo.  [F]   Windows 媒体功能包
	echo.  [G]   Windows 便携设备
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft Office 桌面 UWP 应用
	echo.  [L]   Microsoft DaRT 10.0 工具集
	echo.  [M]   Microsoft DirectX 9.0c
	echo.  [N]   Microsoft 游戏
	echo.  [O]   Windows 边栏
	echo.  [P]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPX /N /M "请输入你的选项 ："
	if errorlevel 17 goto :IntegrateMenu
	if errorlevel 16 goto :IntVCRuntime
	if errorlevel 15 goto :IntSidebar
	if errorlevel 14 goto :IntGames
	if errorlevel 13 goto :IntDirectX9c
	if errorlevel 12 goto :IntDaRT
	if errorlevel 11 goto :IntOfficeUWPApps
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntOpenSSH
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntPortableDevices
	if errorlevel 6  goto :IntMediaFeaturePack
	if errorlevel 5  goto :IntWinToGo
	if errorlevel 4  goto :IntBraille
	if errorlevel 3  goto :IntWin32Calc
	if errorlevel 2  goto :IntEdgeChromium
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v2004/v2009 32-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x86" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft Edge Chromium 浏览器
	echo.  [C]   Microsoft Win32 计算器
	echo.  [D]   Windows 盲文辅助功能
	echo.  [E]   Windows 媒体功能包
	echo.  [F]   Windows 便携设备
	echo.  [G]   Windows PowerShell 7.0
	echo.  [H]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [I]   Microsoft 默认 Metro 应用
	echo.  [J]   Microsoft Office 桌面 UWP 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntOfficeUWPApps
	if errorlevel 9  goto :IntMetroApps
	if errorlevel 8  goto :IntOpenSSH
	if errorlevel 7  goto :IntPowerShell7
	if errorlevel 6  goto :IntPortableDevices
	if errorlevel 5  goto :IntMediaFeaturePack
	if errorlevel 4  goto :IntBraille
	if errorlevel 3  goto :IntWin32Calc
	if errorlevel 2  goto :IntEdgeChromium
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1511 64-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10586" if "%ImageArchitecture%" equ "x64" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.6.2
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 重复数据删除
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntDedup
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX462
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1607 64-位客户端版本企业版 LTSB 2016
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" if "%ImageFlag%" equ "EnterpriseS" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Windows 重复数据删除
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntDedup
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1607 64-位客户端版本企业版 N LTSB 2016
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" if "%ImageFlag%" equ "EnterpriseSN" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Windows 重复数据删除
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntDedup
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1607 64-位客户端版本非企业版（N）LTSB 2016
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Windows 重复数据删除
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   远程服务器管理工具 ^(RSAT^)
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntRSAT
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntDedup
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1703 64-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "15063" if "%ImageArchitecture%" equ "x64" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 盲文辅助功能
	echo.  [F]   Windows 重复数据删除
	echo.  [G]   Windows To Go 工作区
	echo.  [H]   Windows 媒体功能包
	echo.  [I]   Windows PowerShell 7.0
	echo.  [J]   远程服务器管理工具 ^(RSAT^)
	echo.  [K]   Microsoft 默认 Metro 应用
	echo.  [L]   Microsoft DaRT 10.0 工具集
	echo.  [M]   Microsoft DirectX 9.0c
	echo.  [N]   Microsoft 游戏
	echo.  [O]   Windows 边栏
	echo.  [P]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPX /N /M "请输入你的选项 ："
	if errorlevel 17 goto :IntegrateMenu
	if errorlevel 16 goto :IntVCRuntime
	if errorlevel 15 goto :IntSidebar
	if errorlevel 14 goto :IntGames
	if errorlevel 13 goto :IntDirectX9c
	if errorlevel 12 goto :IntDaRT
	if errorlevel 11 goto :IntMetroApps
	if errorlevel 10 goto :IntRSAT
	if errorlevel 9  goto :IntPowerShell7
	if errorlevel 8  goto :IntMediaFeaturePack
	if errorlevel 7  goto :IntWinToGo
	if errorlevel 6  goto :IntDedup
	if errorlevel 5  goto :IntBraille
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1709 64-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "16299" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 盲文辅助功能
	echo.  [F]   Windows 重复数据删除
	echo.  [G]   Windows To Go 工作区
	echo.  [H]   Windows 媒体功能包
	echo.  [I]   Windows PowerShell 7.0
	echo.  [J]   远程服务器管理工具 ^(RSAT^)
	echo.  [K]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [L]   Microsoft 默认 Metro 应用
	echo.  [M]   Microsoft DaRT 10.0 工具集
	echo.  [N]   Microsoft DirectX 9.0c
	echo.  [O]   Microsoft 游戏
	echo.  [P]   Windows 边栏
	echo.  [Q]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQX /N /M "请输入你的选项 ："
	if errorlevel 18 goto :IntegrateMenu
	if errorlevel 17 goto :IntVCRuntime
	if errorlevel 16 goto :IntSidebar
	if errorlevel 15 goto :IntGames
	if errorlevel 14 goto :IntDirectX9c
	if errorlevel 13 goto :IntDaRT
	if errorlevel 12 goto :IntMetroApps
	if errorlevel 11 goto :IntOpenSSH
	if errorlevel 10 goto :IntRSAT
	if errorlevel 9  goto :IntPowerShell7
	if errorlevel 8  goto :IntMediaFeaturePack
	if errorlevel 7  goto :IntWinToGo
	if errorlevel 6  goto :IntDedup
	if errorlevel 5  goto :IntBraille
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1803 64-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17134" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 盲文辅助功能
	echo.  [F]   Windows 重复数据删除
	echo.  [G]   Windows To Go 工作区
	echo.  [H]   Windows 媒体功能包
	echo.  [I]   Windows PowerShell 7.0
	echo.  [J]   远程服务器管理工具 ^(RSAT^)
	echo.  [K]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [L]   Microsoft 默认 Metro 应用
	echo.  [M]   Microsoft Office 桌面 UWP 应用
	echo.  [N]   Microsoft DaRT 10.0 工具集
	echo.  [O]   Microsoft DirectX 9.0c
	echo.  [P]   Microsoft 游戏
	echo.  [Q]   Windows 边栏
	echo.  [R]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRX /N /M "请输入你的选项 ："
	if errorlevel 19 goto :IntegrateMenu
	if errorlevel 18 goto :IntVCRuntime
	if errorlevel 17 goto :IntSidebar
	if errorlevel 16 goto :IntGames
	if errorlevel 15 goto :IntDirectX9c
	if errorlevel 14 goto :IntDaRT
	if errorlevel 13 goto :IntOfficeUWPApps
	if errorlevel 12 goto :IntMetroApps
	if errorlevel 11 goto :IntOpenSSH
	if errorlevel 10 goto :IntRSAT
	if errorlevel 9  goto :IntPowerShell7
	if errorlevel 8  goto :IntMediaFeaturePack
	if errorlevel 7  goto :IntWinToGo
	if errorlevel 6  goto :IntDedup
	if errorlevel 5  goto :IntBraille
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1809 64-位客户端版本企业版 LTSC 2019
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" if "%ImageFlag%" equ "EnterpriseS" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Microsoft Win32 计算器
	echo.  [F]   Windows 盲文辅助功能
	echo.  [G]   Windows 重复数据删除
	echo.  [H]   Windows To Go 工作区
	echo.  [I]   Windows 媒体功能包
	echo.  [J]   Windows 便携设备
	echo.  [K]   Windows PowerShell 7.0
	echo.  [L]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [M]   Microsoft 默认 Metro 应用
	echo.  [N]   Microsoft Office 桌面 UWP 应用
	echo.  [O]   Microsoft DaRT 10.0 工具集
	echo.  [P]   Microsoft DirectX 9.0c
	echo.  [Q]   Microsoft 游戏
	echo.  [R]   Windows 边栏
	echo.  [S]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRSX /N /M "请输入你的选项 ："
	if errorlevel 20 goto :IntegrateMenu
	if errorlevel 19 goto :IntVCRuntime
	if errorlevel 18 goto :IntSidebar
	if errorlevel 17 goto :IntGames
	if errorlevel 16 goto :IntDirectX9c
	if errorlevel 15 goto :IntDaRT
	if errorlevel 14 goto :IntOfficeUWPApps
	if errorlevel 13 goto :IntMetroApps
	if errorlevel 12 goto :IntOpenSSH
	if errorlevel 11 goto :IntPowerShell7
	if errorlevel 10 goto :IntPortableDevices
	if errorlevel 9  goto :IntMediaFeaturePack
	if errorlevel 8  goto :IntWinToGo
	if errorlevel 7  goto :IntDedup
	if errorlevel 6  goto :IntBraille
	if errorlevel 5  goto :IntWin32Calc
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1809 64-位客户端版本企业版 N LTSC 2019
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" if "%ImageFlag%" equ "EnterpriseSN" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Microsoft Win32 计算器
	echo.  [F]   Windows 盲文辅助功能
	echo.  [G]   Windows 重复数据删除
	echo.  [H]   Windows To Go 工作区
	echo.  [I]   Windows 媒体功能包
	echo.  [J]   Windows 便携设备
	echo.  [K]   Windows PowerShell 7.0
	echo.  [L]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [M]   Microsoft 默认 Metro 应用
	echo.  [N]   Microsoft Office 桌面 UWP 应用
	echo.  [O]   Microsoft DaRT 10.0 工具集
	echo.  [P]   Microsoft DirectX 9.0c
	echo.  [Q]   Microsoft 游戏
	echo.  [R]   Windows 边栏
	echo.  [S]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRSX /N /M "请输入你的选项 ："
	if errorlevel 20 goto :IntegrateMenu
	if errorlevel 19 goto :IntVCRuntime
	if errorlevel 18 goto :IntSidebar
	if errorlevel 17 goto :IntGames
	if errorlevel 16 goto :IntDirectX9c
	if errorlevel 15 goto :IntDaRT
	if errorlevel 14 goto :IntOfficeUWPApps
	if errorlevel 13 goto :IntMetroApps
	if errorlevel 12 goto :IntOpenSSH
	if errorlevel 11 goto :IntPowerShell7
	if errorlevel 10 goto :IntPortableDevices
	if errorlevel 9  goto :IntMediaFeaturePack
	if errorlevel 8  goto :IntWinToGo
	if errorlevel 7  goto :IntDedup
	if errorlevel 6  goto :IntBraille
	if errorlevel 5  goto :IntWin32Calc
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1809 64-位客户端版本非企业版（N）LTSC 2019
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Microsoft Win32 计算器
	echo.  [E]   Windows 盲文辅助功能
	echo.  [F]   Windows 重复数据删除
	echo.  [G]   Windows To Go 工作区
	echo.  [H]   Windows 媒体功能包
	echo.  [I]   Windows 便携设备
	echo.  [J]   Windows PowerShell 7.0
	echo.  [K]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [L]   Microsoft 默认 Metro 应用
	echo.  [M]   Microsoft Office 桌面 UWP 应用
	echo.  [N]   Microsoft DaRT 10.0 工具集
	echo.  [O]   Microsoft DirectX 9.0c
	echo.  [P]   Microsoft 游戏
	echo.  [Q]   Windows 边栏
	echo.  [R]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRX /N /M "请输入你的选项 ："
	if errorlevel 19 goto :IntegrateMenu
	if errorlevel 18 goto :IntVCRuntime
	if errorlevel 17 goto :IntSidebar
	if errorlevel 16 goto :IntGames
	if errorlevel 15 goto :IntDirectX9c
	if errorlevel 14 goto :IntDaRT
	if errorlevel 13 goto :IntOfficeUWPApps
	if errorlevel 12 goto :IntMetroApps
	if errorlevel 11 goto :IntOpenSSH
	if errorlevel 10 goto :IntPowerShell7
	if errorlevel 9  goto :IntPortableDevices
	if errorlevel 8  goto :IntMediaFeaturePack
	if errorlevel 7  goto :IntWinToGo
	if errorlevel 6  goto :IntDedup
	if errorlevel 5  goto :IntBraille
	if errorlevel 4  goto :IntWin32Calc
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1903/v1909 64-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageBuild%" leq "18363" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft Edge Chromium 浏览器
	echo.  [C]   Microsoft Win32 计算器
	echo.  [D]   Windows 盲文辅助功能
	echo.  [E]   Windows 重复数据删除
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows 媒体功能包
	echo.  [H]   Windows 便携设备
	echo.  [I]   Windows PowerShell 7.0
	echo.  [J]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [K]   Microsoft 默认 Metro 应用
	echo.  [L]   Microsoft Office 桌面 UWP 应用
	echo.  [M]   Microsoft DaRT 10.0 工具集
	echo.  [N]   Microsoft DirectX 9.0c
	echo.  [O]   Microsoft 游戏
	echo.  [P]   Windows 边栏
	echo.  [Q]   Microsoft Visual C++ Runtime
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQX /N /M "请输入你的选项 ："
	if errorlevel 18 goto :IntegrateMenu
	if errorlevel 17 goto :IntVCRuntime
	if errorlevel 16 goto :IntSidebar
	if errorlevel 15 goto :IntGames
	if errorlevel 14 goto :IntDirectX9c
	if errorlevel 13 goto :IntDaRT
	if errorlevel 12 goto :IntOfficeUWPApps
	if errorlevel 11 goto :IntMetroApps
	if errorlevel 10 goto :IntOpenSSH
	if errorlevel 9  goto :IntPowerShell7
	if errorlevel 8  goto :IntPortableDevices
	if errorlevel 7  goto :IntMediaFeaturePack
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntDedup
	if errorlevel 4  goto :IntBraille
	if errorlevel 3  goto :IntWin32Calc
	if errorlevel 2  goto :IntEdgeChromium
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v2004/v2009 64-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" if "%ImageInstallationType%" equ "Client" if "%ImageArchitecture%" equ "x64" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft Edge Chromium 浏览器
	echo.  [C]   Microsoft Win32 计算器
	echo.  [D]   Windows 盲文辅助功能
	echo.  [E]   Windows 重复数据删除
	echo.  [F]   Windows 媒体功能包
	echo.  [G]   Windows 便携设备
	echo.  [H]   Windows PowerShell 7.0
	echo.  [I]   Open Secure Shell ^(SSH^) 客户端和服务器端
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft Office 桌面 UWP 应用
	echo.  [L]   Microsoft DaRT 10.0 工具集
	echo.  [M]   Microsoft DirectX 9.0c
	echo.  [N]   Microsoft 游戏
	echo.  [O]   Windows 边栏
	echo.  [P]   Microsoft Visual C++ Runtime
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPX /N /M "请输入你的选项 ："
	if errorlevel 17 goto :IntegrateMenu
	if errorlevel 16 goto :IntVCRuntime
	if errorlevel 15 goto :IntSidebar
	if errorlevel 14 goto :IntGames
	if errorlevel 13 goto :IntDirectX9c
	if errorlevel 12 goto :IntDaRT
	if errorlevel 11 goto :IntOfficeUWPApps
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntOpenSSH
	if errorlevel 8  goto :IntPowerShell7
	if errorlevel 7  goto :IntPortableDevices
	if errorlevel 6  goto :IntMediaFeaturePack
	if errorlevel 5  goto :IntDedup
	if errorlevel 4  goto :IntBraille
	if errorlevel 3  goto :IntWin32Calc
	if errorlevel 2  goto :IntEdgeChromium
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows 10 v1803/v1809/v1903/v1909 ARM64-位客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17134" if "%ImageArchitecture%" equ "arm64" (
	echo.
	echo.  [1]   Microsoft .NET Framework 3.5
	echo.
	echo.  [2]   Microsoft 默认 Metro 应用
	echo.
	echo.  [3]   Microsoft Office 桌面 UWP 应用
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :IntegrateMenu
	if errorlevel 3  goto :IntOfficeUWPApps
	if errorlevel 2  goto :IntMetroApps
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server 2016 Core 版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Server Core" (
	echo.
	echo.  [1]   Microsoft .NET Framework 3.5
	echo.
	echo.  [2]   Microsoft .NET Framework 4.8
	echo.
	echo.  [3]   Windows PowerShell 7.0
	echo.
	echo.  [4]   适用于 Windows 的 Linux 子系统 ^(WSL^)
	echo.
	echo.  [5]   Microsoft DaRT 10.0 工具集
	echo.
	echo.  [6]   Microsoft DirectX 9.0c
	echo.
	echo.  [7]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:1234567X /N /M "请输入你的选项 ："
	if errorlevel 8 goto :IntegrateMenu
	if errorlevel 7 goto :IntVCRuntime
	if errorlevel 6 goto :IntDirectX9c
	if errorlevel 5 goto :IntDaRT
	if errorlevel 4 goto :IntWSL
	if errorlevel 3 goto :IntPowerShell7
	if errorlevel 2 goto :IntNetFX48
	if errorlevel 1 goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server 2016
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Server" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Windows Multimedia Restricted Codecs
	echo.  [F]   Windows 系统恢复
	echo.  [G]   适用于 Windows 的 Linux 子系统 ^(WSL^) 
	echo.  [H]   Windows To Go 工作区
	echo.  [I]   Windows PowerShell 7.0
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntPowerShell7
	if errorlevel 8  goto :IntWinToGo
	if errorlevel 7  goto :IntWSL
	if errorlevel 6  goto :IntSystemRestore
	if errorlevel 5  goto :IntMMRC
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server v1709/v1803/Server 2019/v1809 Core 版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "16299" if "%ImageBuild%" leq "17763" if "%ImageInstallationType%" equ "Server Core" (
	echo.
	echo.  [1]   Microsoft .NET Framework 3.5
	echo.
	echo.  [2]   Microsoft .NET Framework 4.8
	echo.
	echo.  [3]   Windows PowerShell 7.0
	echo.
	echo.  [4]   适用于 Windows 的 Linux 子系统 ^(WSL^)
	echo.
	echo.  [5]   Microsoft DaRT 10.0 工具集
	echo.
	echo.  [6]   Microsoft DirectX 9.0c
	echo.
	echo.  [7]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:1234567X /N /M "请输入你的选项 ："
	if errorlevel 8 goto :IntegrateMenu
	if errorlevel 7 goto :IntVCRuntime
	if errorlevel 6 goto :IntDirectX9c
	if errorlevel 5 goto :IntDaRT
	if errorlevel 4 goto :IntWSL
	if errorlevel 3 goto :IntPowerShell7
	if errorlevel 2 goto :IntNetFX48
	if errorlevel 1 goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server v1709/v1803/Server 2019/v1809
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "16299" if "%ImageBuild%" leq "17763" if "%ImageInstallationType%" equ "Server" (
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft .NET Framework 4.8
	echo.  [C]   Microsoft Edge 经典浏览器
	echo.  [D]   Microsoft Edge Chromium 浏览器
	echo.  [E]   Windows Multimedia Restricted Codecs
	echo.  [F]   Windows 系统恢复
	echo.  [G]   适用于 Windows 的 Linux 子系统 ^(WSL^) 
	echo.  [H]   Windows To Go 工作区
	echo.  [I]   Windows PowerShell 7.0
	echo.  [J]   Microsoft 默认 Metro 应用
	echo.  [K]   Microsoft DaRT 10.0 工具集
	echo.  [L]   Microsoft DirectX 9.0c
	echo.  [M]   Microsoft 游戏
	echo.  [N]   Windows 边栏
	echo.  [O]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOX /N /M "请输入你的选项 ："
	if errorlevel 16 goto :IntegrateMenu
	if errorlevel 15 goto :IntVCRuntime
	if errorlevel 14 goto :IntSidebar
	if errorlevel 13 goto :IntGames
	if errorlevel 12 goto :IntDirectX9c
	if errorlevel 11 goto :IntDaRT
	if errorlevel 10 goto :IntMetroApps
	if errorlevel 9  goto :IntPowerShell7
	if errorlevel 8  goto :IntWinToGo
	if errorlevel 7  goto :IntWSL
	if errorlevel 6  goto :IntSystemRestore
	if errorlevel 5  goto :IntMMRC
	if errorlevel 4  goto :IntEdgeChromium
	if errorlevel 3  goto :IntEdgeClassic
	if errorlevel 2  goto :IntNetFX48
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server v1903/v1909 Core 版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageInstallationType%" equ "Server Core" (
	echo.
	echo.  [1]   Microsoft .NET Framework 3.5
	echo.
	echo.  [2]   Windows PowerShell 7.0
	echo.
	echo.  [3]   适用于 Windows 的 Linux 子系统 ^(WSL^)
	echo.
	echo.  [4]   Microsoft DaRT 10.0 工具集
	echo.
	echo.  [5]   Microsoft DirectX 9.0c
	echo.
	echo.  [6]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123456X /N /M "请输入你的选项 ："
	if errorlevel 7 goto :IntegrateMenu
	if errorlevel 6 goto :IntVCRuntime
	if errorlevel 5 goto :IntDirectX9c
	if errorlevel 4 goto :IntDaRT
	if errorlevel 3 goto :IntWSL
	if errorlevel 2 goto :IntPowerShell7
	if errorlevel 1 goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server v1903/v1909
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageBuild%" leq "18363" if "%ImageInstallationType%" equ "Server" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft Edge 经典浏览器
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Windows Multimedia Restricted Codecs
	echo.  [E]   适用于 Windows 的 Linux 子系统 ^(WSL^) 
	echo.  [F]   Windows To Go 工作区
	echo.  [G]   Windows PowerShell 7.0
	echo.  [H]   Microsoft 默认 Metro 应用
	echo.  [I]   Microsoft DaRT 10.0 工具集
	echo.  [J]   Microsoft DirectX 9.0c
	echo.  [K]   Microsoft 游戏
	echo.  [L]   Windows 边栏
	echo.  [M]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMX /N /M "请输入你的选项 ："
	if errorlevel 14 goto :IntegrateMenu
	if errorlevel 13 goto :IntVCRuntime
	if errorlevel 12 goto :IntSidebar
	if errorlevel 11 goto :IntGames
	if errorlevel 10 goto :IntDirectX9c
	if errorlevel 9  goto :IntDaRT
	if errorlevel 8  goto :IntMetroApps
	if errorlevel 7  goto :IntPowerShell7
	if errorlevel 6  goto :IntWinToGo
	if errorlevel 5  goto :IntWSL
	if errorlevel 4  goto :IntMMRC
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntEdgeClassic
	if errorlevel 1  goto :IntNetFX35
)

:: 检查所选择的源操作系统是否是 Windows Server v2004/v2009
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" if "%ImageInstallationType%" equ "Server" (
	echo.
	echo.  [A]   Microsoft .NET Framework 3.5
	echo.  [B]   Microsoft Edge 经典浏览器
	echo.  [C]   Microsoft Edge Chromium 浏览器
	echo.  [D]   Windows Multimedia Restricted Codecs
	echo.  [E]   适用于 Windows 的 Linux 子系统 ^(WSL^) 
	echo.  [F]   Windows PowerShell 7.0
	echo.  [G]   Microsoft 默认 Metro 应用
	echo.  [H]   Microsoft DaRT 10.0 工具集
	echo.  [I]   Microsoft DirectX 9.0c
	echo.  [J]   Microsoft 游戏
	echo.  [K]   Windows 边栏
	echo.  [L]   Microsoft Visual C++ Runtime
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLX /N /M "请输入你的选项 ："
	if errorlevel 13 goto :IntegrateMenu
	if errorlevel 12 goto :IntVCRuntime
	if errorlevel 11 goto :IntSidebar
	if errorlevel 10 goto :IntGames
	if errorlevel 9  goto :IntDirectX9c
	if errorlevel 8  goto :IntDaRT
	if errorlevel 7  goto :IntMetroApps
	if errorlevel 6  goto :IntPowerShell7
	if errorlevel 5  goto :IntWSL
	if errorlevel 4  goto :IntMMRC
	if errorlevel 3  goto :IntEdgeChromium
	if errorlevel 2  goto :IntEdgeClassic
	if errorlevel 1  goto :IntNetFX35
)
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 集成 Windows 自定义定制功能菜单
::-------------------------------------------------------------------------------------------
:IntCustomFeatures

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 集成 Windows 自定义定制功能菜单
echo.===============================================================================

if "%IsDialogsEnabled%" equ "Yes" (
	cls
	echo.===============================================================================
	echo.                MSMG 工具箱 - 集成 Windows 自定义定制功能菜单
	echo.===============================================================================
	echo.
	echo.
	echo.
	echo.                                警         告
	echo.                                =============
	echo.
	echo.   集成 Windows 自定义定制功能将会涉及到修补系统文件，因此 SFC 可以报告有关 
	echo.   Windows 系统文件损坏的信息，这属于正常现象。
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.   若要关闭此警告对话框，请在工具 -^> 选项菜单中选择禁用对话框
	echo.
	echo.===============================================================================
	echo.
	choice /C:YN /N /M "你想要继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :IntegrateMenu
)

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 集成 Windows 自定义定制功能菜单
echo.===============================================================================
:: 检查所选择的源操作系统是否是 Windows 7 客户端版本/Server 2008 R2 非 Core 版本
if "%selectedSourceOS%" equ "w7" if "%ImageInstallationType%" neq "Embedded" if "%ImageInstallationType%" neq "Server Core" (
	echo.
	echo.  [1]   Microsoft 终端服务器补丁
	echo.
	echo.  [2]   自定义主题 UxTheme 补丁
	echo.
	echo.  [3]   自定义 Windows 恢复环境 ^(WinRE^)
	echo.
	echo.  [4]   自定义默认用户帐户图片
	echo.
	echo.  [5]   自定义系统文件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:12345X /N /M "请输入你的选项 ："
	if errorlevel 6 goto :IntegrateMenu
	if errorlevel 5 goto :IntCustomFiles
	if errorlevel 4 goto :IntUAP
	if errorlevel 3 goto :IntCustomRecoveryImage
	if errorlevel 2 goto :IntCustomUxTheme
	if errorlevel 1 goto :IntCustomTerminalServer
)

:: 检查所选择的源操作系统是否是 Windows 7 Embedded 版本
if "%selectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Embedded" (
	echo.
	echo.  [1]   Microsoft 终端服务器补丁
	echo.
	echo.  [2]   自定义主题 UxTheme 补丁
	echo.
	echo.  [3]   自定义默认用户帐户图片
	echo.
	echo.  [4]   自定义系统文件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:1234X /N /M "请输入你的选项 ："
	if errorlevel 5 goto :IntegrateMenu
	if errorlevel 4 goto :IntCustomFiles
	if errorlevel 3 goto :IntUAP
	if errorlevel 2 goto :IntCustomUxTheme
	if errorlevel 1 goto :IntCustomTerminalServer
)

:: 检查所选择的源操作系统是否是 Windows Server 2008 Core 版本
if "%selectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Server Core" (
	echo.
	echo.  [1]   Microsoft 终端服务器补丁
	echo.
	echo.  [2]   自定义 Windows 恢复环境 ^(WinRE^)
	echo.
	echo.  [3]   自定义系统文件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :IntegrateMenu
	if errorlevel 3 goto :IntCustomFiles
	if errorlevel 2 goto :IntCustomRecoveryImage
	if errorlevel 1 goto :IntCustomTerminalServer
)

:: 检查所选择的源操作系统是否是 Windows 8.1 客户端版本非专业版（含 WMC）/Server 2012 R2 非 Core 版本
if "%selectedSourceOS%" equ "w81" if "%ImageFlag%" neq "ProfessionalWMC" if "%ImageInstallationType%" neq "Server Core" (
	echo.
	echo.  [1]   Windows 8.1 预激活数据
	echo.
	echo.  [2]   Microsoft 终端服务器补丁
	echo.
	echo.  [3]   自定义主题 UxTheme 补丁
	echo.
	echo.  [4]   自定义 Windows 恢复环境 ^(WinRE^)
	echo.
	echo.  [5]   自定义默认用户帐户图片
	echo.
	echo.  [6]   自定义系统文件
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123456X /N /M "请输入你的选项 ："
	if errorlevel 7 goto :IntegrateMenu
	if errorlevel 6 goto :IntCustomFiles
	if errorlevel 5 goto :IntUAP
	if errorlevel 4 goto :IntCustomRecoveryImage
	if errorlevel 3 goto :IntCustomUxTheme
	if errorlevel 2 goto :IntCustomTerminalServer
	if errorlevel 1 goto :IntPreActTokens
)

:: 检查所选择的源操作系统是否是 Windows 8.1 专业版（含 WMC）
if "%selectedSourceOS%" equ "w81" if "%ImageEdition%" equ "ProfessionalWMC" (
	echo.
	echo.  [1]   Windows 8.1 Media Center 通用激活令牌
	echo.
	echo.  [2]   Windows 8.1 预激活数据
	echo.
	echo.  [3]   Microsoft 终端服务器补丁
	echo.
	echo.  [4]   自定义主题 UxTheme 补丁
	echo.
	echo.  [5]   自定义 Windows 恢复环境 ^(WinRE^)
	echo.
	echo.  [6]   自定义默认用户帐户图片
	echo.
	echo.  [7]   自定义系统文件
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	choice /C:1234567X /N /M "请输入你的选项 ："
	if errorlevel 8 goto :IntegrateMenu
	if errorlevel 7 goto :IntCustomFiles
	if errorlevel 6 goto :IntUAP
	if errorlevel 5 goto :IntCustomRecoveryImage
	if errorlevel 4 goto :IntCustomUxTheme
	if errorlevel 3 goto :IntCustomTerminalServer
	if errorlevel 2 goto :IntPreActTokens
	if errorlevel 1 goto :IntWMCGActTokens
)

:: 检查所选择的源操作系统是否是 Windows Server 2012 R2 Core 版本
if "%selectedSourceOS%" equ "w81" if "%ImageInstallationType%" equ "Server Core" (
	echo.
	echo.  [1]   Microsoft 终端服务器补丁
	echo.
	echo.  [2]   自定义 Windows 恢复环境 ^(WinRE^)
	echo.
	echo.  [3]   自定义系统文件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :IntegrateMenu
	if errorlevel 3 goto :IntCustomFiles
	if errorlevel 2 goto :IntCustomRecoveryImage
	if errorlevel 1 goto :IntCustomTerminalServer
)

:: 检查所选择的源操作系统是否是 Windows Server Core 版本
if "%selectedSourceOS%" equ "w10" if "%ImageInstallationType%" equ "Server Core" (
	echo.
	echo.  [1]   Microsoft 终端服务器补丁
	echo.
	echo.  [2]   自定义 Windows 恢复环境 ^(WinRE^)
	echo.
	echo.  [3]   自定义系统文件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :IntegrateMenu
	if errorlevel 3 goto :IntCustomFiles
	if errorlevel 2 goto :IntCustomRecoveryImage
	if errorlevel 1 goto :IntCustomTerminalServer
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端版本/Server 非 Core 版本
if "%selectedSourceOS%" equ "w10" if "%ImageInstallationType%" neq "Server Core" (
	echo.  [1]   Microsoft 终端服务器补丁
	echo.
	echo.  [2]   自定义主题 UxTheme 补丁
	echo.
	echo.  [3]   自定义 Windows 恢复环境 ^(WinRE^)
	echo.
	echo.  [4]   自定义默认用户帐户图片
	echo.
	echo.  [5]   自定义系统文件
	echo.
	echo.  [6]   Microsoft Win32 计算器 Metro 皮肤
	echo.
	echo.  [7]   Windows 照片查看器 Metro 皮肤
	echo.
	echo.  [8]   Windows Media Player Metro 皮肤
	echo.
	echo.
	echo.  [X]   返回
	echo.===============================================================================
	echo.
	choice /C:12345678X /N /M "请输入你的选项 ："
	if errorlevel 9 goto :IntegrateMenu
	if errorlevel 8 goto :IntWMPMetroSkin
	if errorlevel 7 goto :IntWPVMetroSkin
	if errorlevel 6 goto :IntWin32CalcMetroSkin	
	if errorlevel 5 goto :IntCustomFiles
	if errorlevel 4 goto :IntUAP
	if errorlevel 3 goto :IntCustomRecoveryImage
	if errorlevel 2 goto :IntCustomUxTheme
	if errorlevel 1 goto :IntCustomTerminalServer
)
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 移除菜单
::-------------------------------------------------------------------------------------------
:RemoveMenu

cls
echo.===============================================================================
echo.                           MSMG 工具箱 - 移除菜单
echo.===============================================================================
echo.

:: 检查源操作系统是否已选择
if "%IsSourceselected%" equ "No" (
	echo.尚未选择源操作系统，请从“源文件”菜单中选择……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查是否加载了映像注册表
if "%IsImageRegistryLoaded%" equ "Yes" (
	echo.已加载源操作系统映像注册表，请使用工具 -^> 选项卸载……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否不是 Windows 10
if "%selectedSourceOS%" neq "w10" (
	echo.  [1]   使用软件包列表移除 Windows 组件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 2015/2016 LTSB
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17134" if "%ImageFlag%" equ "EnterpriseS" (
	echo.  [1]   使用软件包列表移除 Windows 组件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 N 2015/2016 LTSB
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17134" if "%ImageFlag%" equ "EnterpriseSN" (
	echo.  [1]   使用软件包列表移除 Windows 组件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 v1507/v1511/v1607/v1703/v1709/v1803 客户端版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17134" if "%ImageInstallationType%" equ "Client" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	echo.  [1]   使用应用列表移除 Windows 应用
	echo. 
	echo.  [2]   使用软件包列表移除 Windows 组件
	echo.
	echo.
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 2019 LTSC
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" equ "EnterpriseS" (
	echo.  [1]   移除 Windows 组件
	echo. 
	echo.  [2]   使用软件包列表移除 Windows 组件
	echo.
	echo.
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 N 2019 LTSC
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" equ "EnterpriseSN" (
	echo.  [1]   移除 Windows 组件
	echo. 
	echo.  [2]   使用软件包列表移除 Windows 组件
	echo.
	echo.
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端非-EnterpriseS/EnterpriseSN 版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Client" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	echo.  [1]   移除 Windows 组件
	echo.
	echo.  [2]   使用应用列表移除 Windows 应用
	echo.
	echo.  [3]   使用软件包列表移除 Windows 组件
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageBuild%" leq "18363" if "%ImageInstallationType%" equ "Client" (
	echo.  [1]   移除 Windows 组件
	echo.
	echo.  [2]   使用应用列表移除 Windows 应用
	echo.
	echo.  [3]   使用软件包列表移除 Windows 组件
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" if "%ImageInstallationType%" equ "Client" (
	echo.  [1]   移除 Windows 组件
	echo.
	echo.  [2]   使用应用列表移除 Windows 应用
	echo.
	echo.  [3]   使用软件包列表移除 Windows 组件
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" gtr "19042" if "%ImageInstallationType%" equ "Client" (
	echo.  [1]   使用应用列表移除 Windows 应用
	echo. 
	echo.  [2]   使用软件包列表移除 Windows 组件
	echo.
	echo.
	echo.
	echo.
)

:: 检查所选择的源操作系统是否是 Windows Server 版本
if "%selectedSourceOS%" equ "w10" if "%ImageInstallationType:~,6%" equ "Server" (
	echo.  [1]   使用软件包列表移除 Windows 组件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
)

echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
:: 检查所选择的源操作系统是否不是 Windows 10
if "%selectedSourceOS%" neq "w10" (
	choice /C:1X /N /M "请输入你的选项 ："
	if errorlevel 2 goto :MainMenu
	if errorlevel 1 goto :RemoveWindowsComponentsList
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 2015/2016 LTSB
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17134" if "%ImageFlag%" equ "EnterpriseS" (
	choice /C:1X /N /M "请输入你的选项 ："
	if errorlevel 2 goto :MainMenu
	if errorlevel 1 goto :RemoveWindowsComponentsList
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 N 2015/2016 LTSB
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17134" if "%ImageFlag%" equ "EnterpriseSN" (
	choice /C:1X /N /M "请输入你的选项 ："
	if errorlevel 2 goto :MainMenu
	if errorlevel 1 goto :RemoveWindowsComponentsList
)

:: 检查所选择的源操作系统是否是 Windows 10 v1507/v1511/v1607/v1703/v1709/v1803 客户端版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17134" if "%ImageInstallationType%" equ "Client" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :MainMenu
	if errorlevel 2 goto :RemoveWindowsComponentsList
	if errorlevel 1 goto :RemoveWindowsAppsList
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 2019 LTSC
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" equ "EnterpriseS" (
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :MainMenu
	if errorlevel 2 goto :RemoveWindowsComponentsList
	if errorlevel 1 goto :RemoveWindowsComponentsMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 N 2019 LTSC
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" equ "EnterpriseSN" (
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :MainMenu
	if errorlevel 2 goto :RemoveWindowsComponentsList
	if errorlevel 1 goto :RemoveWindowsComponentsMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端非-EnterpriseS/EnterpriseSN 版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Client" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :MainMenu
	if errorlevel 3 goto :RemoveWindowsComponentsList
	if errorlevel 2 goto :RemoveWindowsAppsList
	if errorlevel 1 goto :RemoveWindowsComponentsMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageBuild%" leq "18363" if "%ImageInstallationType%" equ "Client" (
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :MainMenu
	if errorlevel 3 goto :RemoveWindowsComponentsList
	if errorlevel 2 goto :RemoveWindowsAppsList
	if errorlevel 1 goto :RemoveWindowsComponentsMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" if "%ImageInstallationType%" equ "Client" (
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :MainMenu
	if errorlevel 3 goto :RemoveWindowsComponentsList
	if errorlevel 2 goto :RemoveWindowsAppsList
	if errorlevel 1 goto :RemoveWindowsComponentsMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 客户端版本
if "%selectedSourceOS%" equ "w10" if "%ImageBuild%" gtr "19042" if "%ImageInstallationType%" equ "Client" (
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :MainMenu
	if errorlevel 2 goto :RemoveWindowsComponentsList
	if errorlevel 1 goto :RemoveWindowsAppsList
)

:: 检查所选择的源操作系统是否是 Windows Server 版本
if "%selectedSourceOS%" equ "w10" if "%ImageInstallationType:~,6%" equ "Server" (
	choice /C:1X /N /M "请输入你的选项 ："
	if errorlevel 2 goto :MainMenu
	if errorlevel 1 goto :RemoveWindowsComponentsList
)
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 自定义定制菜单
::-------------------------------------------------------------------------------------------
:CustomizeMenu

cls
echo.===============================================================================
echo.                        MSMG 工具箱 - 自定义定制菜单
echo.===============================================================================
echo.
:: 检查源操作系统是否已选择
if "%IsSourceselected%" equ "No" (
	echo.尚未选择源操作系统，请从“源文件”菜单中选择……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查是否加载了映像注册表
if "%IsImageRegistryLoaded%" equ "Yes" (
	echo.已加载源操作系统映像注册表，请使用工具 -^> 选项卸载……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 7/Server 2008 R2
if "%selectedSourceOS%" equ "w7" (
	echo.此功能尚未实现……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

echo.  [1]   使用功能列表启用 Windows 功能
echo.  [2]   使用功能列表禁用 Windows 功能
echo.  [3]   从 XML 文件导入自定义默认 Metro 应用关联
echo.  [4]   将默认 Metro 应用关联导出到 XML 文件
echo.  [5]   移除默认 Metro 应用关联 XML 文件
echo.  [6]   从 XML 文件导入自定义开始菜单布局
echo.  [7]   从注册表文件导入自定义注册表设置
echo.  [8]   应用调整
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:12345678X /N /M "请输入你的选项 ："
if errorlevel 9 goto :MainMenu
if errorlevel 8 goto :ApplyTweaksMenu
if errorlevel 7 goto :ImportCustomRegistry
if errorlevel 6 goto :ImportStartMenuLayout
if errorlevel 5 goto :RemoveMetroAppsAssociation
if errorlevel 4 goto :ExportMetroAppsAssociation
if errorlevel 3 goto :ImportMetroAppsAssociation
if errorlevel 2 goto :DisableFeatures
if errorlevel 1 goto :EnableFeatures
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 应用源文件菜单
::-------------------------------------------------------------------------------------------
:ApplyMenu

cls
echo.===============================================================================
echo.                        MSMG 工具箱 - 应用源文件菜单
echo.===============================================================================
echo.
:: 检查是否加载了映像注册表
if "%IsImageRegistryLoaded%" equ "Yes" (
	echo.已加载源操作系统映像注册表，请使用工具 -^> 选项卸载……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

if "%IsSourceselected%" equ "No" (
	echo.  [1]   重建源映像文件
	echo.
	echo.
	echo.
	echo.
)

if "%IsSourceselected%" equ "Yes" if "%selectedSourceOS%" equ "w7" (
	echo.  [1]   应用并保存到源映像文件
	echo.
	echo.  [2]   丢弃更改并卸载源映像文件
	echo.
	echo.
)

if "%IsSourceselected%" equ "Yes" if "%selectedSourceOS%" neq "w7" (
	echo.  [1]   清理源映像文件
	echo.
	echo.  [2]   应用并保存到源映像文件
	echo.
	echo.  [3]   丢弃更改并卸载源映像文件
)
echo.
echo.
echo.
echo.
echo. 
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.

if "%IsSourceselected%" equ "No" (
	choice /C:1X /N /M "请输入你的选项 ："
	if errorlevel 2 goto :MainMenu
	if errorlevel 1 goto :RebuildSource
)

if "%IsSourceselected%" equ "Yes" if "%selectedSourceOS%" equ "w7" (
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :MainMenu
	if errorlevel 2 goto :DiscardSource
	if errorlevel 1 goto :SaveSource
)

if "%IsSourceselected%" equ "Yes" if "%selectedSourceOS%" neq "w7" (
	choice /C:1234X /N /M "请输入你的选项 ："
	if errorlevel 5 goto :MainMenu
	if errorlevel 3 goto :DiscardSource
	if errorlevel 2 goto :SaveSource
	if errorlevel 1 goto :CleanupSource
)
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 目标选择菜单
::-------------------------------------------------------------------------------------------
:TargetMenu

cls
echo.===============================================================================
echo.                         MSMG 工具箱 - 目标选择菜单
echo.===============================================================================
echo.
echo.  [1]   制作 DVD ISO 镜像
echo.
echo.  [2]   刻录 ISO 镜像到 DVD 光盘
echo.
echo.  [3]   将源文件复制到 USB 闪存驱动器
echo.
echo.  [4]   同步源启动和安装映像到 USB 闪存驱动器
echo.
echo.  [5]   将 ISO 镜像刻录到可启动 USB 闪存驱动器
echo.
echo.  [6]   格式化 USB 闪存驱动器
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:123456X /N /M "请输入你的选项 ："
if errorlevel 7 goto :MainMenu
if errorlevel 6 goto :FormatUSB
if errorlevel 5 goto :BurnUSB
if errorlevel 4 goto :SyncUSB
if errorlevel 3 goto :CopyUSB
if errorlevel 2 goto :BurnISO
if errorlevel 1 goto :MakeISO
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 工具菜单
::-------------------------------------------------------------------------------------------
:ToolsMenu

cls
echo.===============================================================================
echo.                           MSMG 工具箱 - 工具菜单
echo.===============================================================================
echo.
echo.  [1]   WIM 管理器
echo.
echo.  [2]   调试信息
echo.
echo.  [3]   选    项
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:123X /N /M "请输入你的选项 ："
if errorlevel 4 goto :MainMenu
if errorlevel 3 goto :Options
if errorlevel 2 goto :Debug
if errorlevel 1 goto :WIMManager
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 从 <DVD> 文件夹中选择源文件
::-------------------------------------------------------------------------------------------
:SelectSourceDVD

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 从 ^<DVD^> 文件夹中选择源文件
echo.===============================================================================
echo.

:: 检查 Windows 源启动映像是否存在
if not exist "%BootWim%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Boot.wim”映像……
	echo.
	echo.请将 Windows 安装程序中的“Boot.wim”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源安装映像是否为 ESD 格式
if exist "%InstallEsd%" (
	echo.工具箱所找到的 Windows 安装映像是 .esd 格式，ESD 映像是高度压缩的映
	echo.像，无法直接维护。
	echo.
	echo.此工具箱要求 Windows 安装映像以 .wim 格式进行维护。
	echo.
	echo.请使用 .wim 格式的 Windows 安装映像或使用转换菜单将 .esd 映像转换为 
	echo..wim 格式
	echo.
	goto :Stop
)

:: 检查 Windows 源安装映像是否存在
if not exist "%InstallWim%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Install.wim”映像……
	echo.
	echo.请将 Windows 安装程序中的“Install.wim”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在选择源映像文件#########################################################
echo.-------------------------------------------------------------------------------

:: 获取映像索引号以维护
call :GetImageIndexNo "%InstallWim%"

:: 检查映像索引有效性
if "%ImageIndexNo%" equ "" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul
	goto :SelectSourceDVD
)

:: 检查映像索引有效性
if "%ImageIndexNo%" neq "*" if "%ImageIndexNo%" lss "1" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul
	goto :SelectSourceDVD
)

:: 检查映像索引有效性
if "%ImageIndexNo%" neq "*" if "%ImageIndexNo%" gtr %ImageCount% (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul
	goto :SelectSourceDVD
)

:: 获取所选择的映像索引信息
if "%ImageIndexNo%" equ "*" call :GetImageIndexInfo "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageIndexInfo "%InstallWim%", %ImageIndexNo% >nul

:: 设置所选择的源操作系统版本
if "%ImageVersion%" equ "6.1.7601" set "SelectedSourceOS=w7"
if "%ImageVersion%" equ "6.3.9600" set "SelectedSourceOS=w81"
if "%ImageVersion:~0,-6%" equ "10.0" set "SelectedSourceOS=w10"

:: 检查主机操作系统是否是 Windows 7 并是否选择了 Windows 10 源操作系统
if "%HostVersion%" equ "6.1" if "%SelectedSourceOS%" equ "w10" (
	echo.
	echo.工具箱无法在 Windows 7 主机操作系统上维护 Windows 10 源操作系统……
	echo.
	echo.工具箱需要主机操作系统为 Windows 8.1/10 以维护 Windows 10 源操作系统……
	goto :Stop	
)

echo.
choice /C:YN /N /M "你是否要安装 Windows 安装程序启动映像 ？ [是‘Y’/否‘N’] ："
if "%errorlevel%" equ "1" set "IsBootImageSelected=Yes"
if "%errorlevel%" equ "2" set "IsBootImageSelected=No"

echo.
choice /C:YN /N /M "你是否要安装 Windows 恢复映像 ？ [是‘Y’/否‘N’] ："
if "%errorlevel%" equ "1" set "IsRecoveryImageSelected=Yes"
if "%errorlevel%" equ "2" set "IsRecoveryImageSelected=No"

echo.
echo.-------------------------------------------------------------------------------
echo.####源映像文件详细信息#########################################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	echo.    映像文件名称             ： Install.wim
	echo.    映像索引范围             ： 1-%ImageCount%
	echo.    映像体系结构             ： %ImageArchitecture%
	echo.    映像版本                 ： %ImageVersion%
	echo.    映像服务包内部版本       ： %ImageServicePackBuild%
	echo.    映像服务包等级           ： %ImageServicePackLevel%
	echo.    映像内部版本             ： %ImageBuild%
	echo.    映像默认语言             ： %ImageDefaultLanguage%
) else (
	echo.    映像文件名称             ： Install.wim
	echo.    映像索引编号             ： %ImageIndexNo%
	echo.    映像名称                 ： %ImageName%
	echo.    映像描述                 ： %ImageDescription%
	echo.    映像体系结构             ： %ImageArchitecture%
	echo.    映像版本                 ： %ImageVersion%
	echo.    映像服务包内部版本       ： %ImageServicePackBuild%
	echo.    映像服务包等级           ： %ImageServicePackLevel%
	echo.    映像内部版本             ： %ImageBuild%
	echo.    映像版本                 ： %ImageEdition%
	echo.    映像标识                 ： %ImageFlag%
	echo.    映像安装类型             ： %ImageInstallationType%
	echo.    映像默认语言             ： %ImageDefaultLanguage%
)
echo.
echo.-------------------------------------------------------------------------------
echo.####正在安装源映像文件#########################################################
echo.-------------------------------------------------------------------------------
echo.
if "%IsBootImageSelected%" equ "Yes" (
	:: 安装源启动映像索引 1 以维护
	echo.-------------------------------------------------------------------------------
	echo.正在将 [Boot.wim，索引 ：1] 映像安装在 ^<\Mount\Boot\1^>……
	echo.-------------------------------------------------------------------------------
	call :MountImage "%BootWim%", 1, "%BootMount%\1"
	echo.-------------------------------------------------------------------------------

	:: 安装源启动映像索引 2 以维护
	echo.正在将 [Boot.wim，索引 ：2] 映像安装在 ^<\Mount\Boot\2^>……
	echo.-------------------------------------------------------------------------------
	call :MountImage "%BootWim%", 2, "%BootMount%\2"
)

:: 安装源安装和恢复映像索引安装以维护
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		call :CreateFolder "%InstallMount%\%%i"

		:: 安装多个源安装映像索引以维护
		echo.-------------------------------------------------------------------------------
		echo.正在将 [Install.wim，索引 ：%%i] 映像安装在 ^<\Mount\Install\%%i^>……
		echo.-------------------------------------------------------------------------------
		call :MountImage "%InstallWim%", %%i, "%InstallMount%\%%i"

		rem if "%%i" neq "%ImageCount%" echo.-------------------------------------------------------------------------------
	)
	if "%IsRecoveryImageSelected%" equ "Yes" (
		:: 安装源恢复映像索引以维护
		echo.-------------------------------------------------------------------------------
		echo.正在将 [WinRe.wim，索引 ：1] 映像安装在 ^<\Mount\WinRE^>……
		echo.-------------------------------------------------------------------------------
		call :MountImage "%InstallMount%\1\%WinReWim%", 1, "%WinReMount%"
	)
) else (
	:: 安装源安装映像索引以维护
	echo.-------------------------------------------------------------------------------
	echo.正在将 [Install.wim，索引 ：%ImageIndexNo%] 映像安装在 ^<\Mount\Install^>……
	echo.-------------------------------------------------------------------------------
	call :MountImage "%InstallWim%", %ImageIndexNo%, "%InstallMount%"

	:: 安装源恢复映像索引 1 以维护
	if "%IsRecoveryImageSelected%" equ "Yes" if exist "%InstallMount%\%WinReWim%" (
		echo.-------------------------------------------------------------------------------
		echo.正在将 [WinRe.wim，索引 ：1] 映像安装在 ^<\Mount\WinRE^>……
		echo.-------------------------------------------------------------------------------
		call :MountImage "%InstallMount%\%WinReWim%", 1, "%WinReMount%"
	)
)
echo.-------------------------------------------------------------------------------
echo.####选择并安装源映像文件已完成#################################################
echo.-------------------------------------------------------------------------------

set "IsSourceSelected=Yes"

:Stop
echo.
echo.===============================================================================
echo.
pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - Copy Source from DVD Drive to ^<DVD^> 文件夹
::-------------------------------------------------------------------------------------------
:SelectSourceCopy

setlocal

set DriveLetter=

cls
echo.===============================================================================
echo.             MSMG 工具箱 - 从 DVD 驱动器复制源文件到 ^<DVD^> 文件夹
echo.===============================================================================
echo.

:: 检查 Windows 源 DVD 文件夹是否是空的
if exist "%DVD%\sources\*.wim" (
	echo.工具箱中的源 ^<DVD^> 文件夹不是空的……
	echo.
	choice /C:YN /N /M "你想移除它并继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始将源文件从 DVD 驱动器复制到 ^<DVD^> 文件夹###########################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 DVD 驱动器选项####################################################
echo.-------------------------------------------------------------------------------
echo.
:: 获取 DVD 驱动器盘符
set /p DriveLetter=请输入 DVD 驱动器盘符：

:: 设置 DVD 驱动器盘符
set "DriveLetter=%DriveLetter%:"
echo.

:: 检查指定的 DVD 驱动器号是否为空驱动器
if not exist "%DriveLetter%\sources\boot.wim" (
	echo.无法在指定的驱动器号中找到 Windows 操作系统的安装文件……
	echo.
	echo.请输入正确的 DVD 驱动器盘符……
	goto :Stop
)

:: 检查指定的 DVD 驱动器号是否为空驱动器
if not exist "%DriveLetter%\sources\install.wim" (
	echo.无法在指定的驱动器号中找到 Windows 操作系统的安装文件……
	echo.
	echo.请输入正确的 DVD 驱动器盘符……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在从 DVD 驱动器复制源文件到 ^<DVD^> 文件夹#################################
echo.-------------------------------------------------------------------------------
echo.
call :RemoveFolder "%DVD%"
echo.正在从 DVD 驱动器 ^<%DriveLetter%^> 复制源文件到源 ^<DVD^> 文件夹……
echo.
echo.从 DVD 驱动器复制可能会需要一些时间，所以请稍候……
%XCopy% %DriveLetter% "%DVD%" >nul
echo.
echo.复制完成……
echo.
echo.-------------------------------------------------------------------------------
echo.####从 DVD 驱动器复制源文件到 ^<DVD^> 文件夹已完成###############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set DriveLetter=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 从 DVD ISO 镜像解压源文件到 <DVD> 文件夹
::-------------------------------------------------------------------------------------------
:SelectSourceISO

setlocal

set ISOFileName=

cls
echo.===============================================================================
echo.            MSMG 工具箱 - 从 DVD ISO 镜像解压源文件到 ^<DVD^> 文件夹
echo.===============================================================================
echo.

:: 检查 Windows 源 DVD 文件夹是否是空的
if exist "%DVD%\sources\*.wim" (
	echo.工具箱中的源 ^<DVD^> 文件夹不是空的……
	echo.
	choice /C:YN /N /M "你想移除它并继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
	echo.
)

:: 检查 DVD ISO 镜像文件夹是否是空的
if not exist "%ISO%\*.iso" (	
	echo.DVD ISO 镜像文件夹 ^<ISO^> 是空的……
	echo.
	echo.请将 DVD ISO 镜像复制到 ^<ISO^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始从 DVD ISO 镜像解压源文件到 ^<DVD^> 文件夹###########################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 DVD ISO 镜像选项##################################################
echo.-------------------------------------------------------------------------------
echo.
:: 获取 DVD ISO 映像文件名称
set /p ISOFileName=请输入 ISO 镜像文件名称，不含 .iso ：

:: 设置 DVD ISO 映像文件名称
set "ISOFileName=%ISOFileName%.iso"
echo.

:: 检查指定的 DVD ISO 镜像文件是否存在
if not exist "%ISO%\%ISOFileName%" (
	echo.无法在 ^<ISO^> 文件夹中找到指定的 DVD ISO 镜像……
	echo.
	echo.请输入正确的 DVD ISO 镜像文件名称……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在将源文件从 DVD ISO 镜像解压到 ^<DVD^> 文件夹#############################
echo.-------------------------------------------------------------------------------
echo.
call :RemoveFolder "%DVD%"
echo.正在解压 DVD ISO 镜像内容到源 ^<DVD^> 文件夹……
echo.
echo.解压可能需要一些时间，所以请稍等……
%Zip% x -y "%ISO%\%ISOFileName%" -o"%DVD%" >nul
echo.
set /a n=0
if exist "%DVD%\sources\boot.wim" set /a n+=1
if exist "%DVD%\sources\install.wim" set /a n+=1
if exist "%DVD%\sources\install.esd" set /a n+=1
if "%n%" equ "2" (echo.解压完成……) else echo.解压失败……
echo.
echo.-------------------------------------------------------------------------------
echo.####从 DVD ISO 镜像解压源文件到 ^<DVD^> 文件夹已完成#############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set ISOFileName=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 从 OEM IMG 镜像解压源文件到 <DVD> 文件夹
::-------------------------------------------------------------------------------------------
:SelectSourceIMG

setlocal

set IMGFileName=

cls
echo.===============================================================================
echo.            MSMG 工具箱 - 从 OEM IMG 镜像解压源文件到 ^<DVD^> 文件夹
echo.===============================================================================
echo.

:: 检查 Windows 源 DVD 文件夹是否是空的
if exist "%DVD%\sources\*.wim" (
	echo.工具箱中的源 ^<DVD^> 文件夹不是空的……
	echo.
	choice /C:YN /N /M "你想移除它并继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

:: 检查 OEM IMG 文件夹是否为空
if not exist "%ISO%\*.img" (
	echo.无法在 ^<ISO^> 文件夹中找到 Windows OEM IMG 安装镜像文件……
	echo.
	echo.请将 Windows OEM IMG 安装镜像文件复制到 ^<ISO^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始从 OEM IMG 镜像解压源文件到 ^<DVD^> 文件夹###########################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 OEM IMG 镜像选项##################################################
echo.-------------------------------------------------------------------------------
echo.
:: 获取 OEM IMG 文件名称
set /p IMGFileName=请输入 OEM IMG 镜像文件名称，不含 .img 扩展名 ：

:: 设置 OEM IMG 文件名称
set "IMGFileName=%IMGFileName%.img"
echo.

:: 检查指定的 OEM IMG 镜像文件是否存在
if not exist "%ISO%\%IMGFileName%" (
	echo.无法找到指定的 OEM IMG 镜像文件……
	echo.
	echo.请输入正确的 OEM IMG 镜像文件名称……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在将源文件从 OEM IMG 镜像解压到 ^<DVD^> 文件夹#############################
echo.-------------------------------------------------------------------------------
echo.
call :RemoveFolder "%DVD%"
echo.正在解压 OEM IMG 镜像内容到源 ^<DVD^> 文件夹……
echo.
echo.解压可能需要一些时间，所以请稍等……
%Zip% x -y "%ISO%\%IMGFileName%" -o"%DVD%" >nul
echo.
set /a n=0
if exist "%DVD%\sources\boot.wim" set /a n+=1
if exist "%DVD%\sources\install.wim" set /a n+=1
if "%n%" equ "2" (echo.解压完成……) else echo.解压失败……
echo.
echo.-------------------------------------------------------------------------------
echo.####从 OEM IMG 镜像解压源文件到 ^<DVD^> 文件夹已完成#############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set IMGFileName=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 转换 Windows 8.1/10 应用商店 ESD 映像为 WIM 映像
::-------------------------------------------------------------------------------------------
:ConvertStoreEsd2Wim

setlocal

set ESDBuild=
set ESDImageCount=
set ESDImageIndex=

cls
echo.===============================================================================
echo.            MSMG 工具箱 - 转换 Windows 应用商店 ESD 映像为 WIM 映像
echo.===============================================================================
echo.

:: 检查 Windows 源 DVD 文件夹是否是空的
if not exist "%InstallEsd%" (
	echo.无法在 ^<DVD\Sources^> 文件夹中找到 Windows 应用商店 ESD 映像文件“Install.esd”……
	echo.
	echo.请将 Windows 应用商店 ESD 映像文件复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

:: 查找当前 ESD 映像中的总索引数量
for /f "tokens=2 delims=: " %%i in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" ^| findstr /i Index') do (set ESDImageCount=%%i)

echo.-------------------------------------------------------------------------------
echo.####正在开始转换 Windows 应用商店 ESD 映像为 WIM 映像##########################
echo.-------------------------------------------------------------------------------
echo.
echo.正在读取映像信息……
echo.
echo.===============================================================================
echo.^|索引    ^|体系结构    ^|名称
echo.===============================================================================
for /f "tokens=2 delims=: " %%a in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" ^| findstr /i Index') do (
	for /f "tokens=2 delims=:" %%b in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" /Index:%%a ^| findstr /i Architecture') do (
		for /f "tokens=2 delims=:  " %%c in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" /Index:%%a ^| findstr /i Name') do (
			if %%a equ 1 echo.^|%%a       ^|  -          ^|%%c
			if %%a gtr 1 if %%a leq 9 echo.^|%%a       ^|%%b          ^|%%c
			if %%a gtr 9 echo.^|%%a      ^|%%b          ^|%%c
		)
	)
)
echo.===============================================================================
echo.
if "%ESDImageCount%" gtr "4" ( 
	set /p ESDImageIndex=请输入 ESD 映像索引编号的 # [范围 ：4-%ESDImageCount%，* - 全部] ：

	if "%ESDImageIndex%" neq "*" if "%ESDImageIndex%" lss "1" (
		echo. 
		echo.输入的索引编号无效，有效范围为 [4-%ESDImageCount%]
		echo.
		echo.请按 Enter 键再试一次……
		pause >nul

		goto :ConvertStoreEsd2Wim
	)

	if "%ESDImageIndex%" neq "*" if "%ESDImageIndex%" gtr %ESDImageCount% (
		echo. 
		echo.输入的索引编号无效，有效范围为 [4-%ESDImageCount%]
		echo.
		echo.请按 Enter 键再试一次……
		pause >nul

		goto :ConvertStoreEsd2Wim
	)

	echo.
)
echo.-------------------------------------------------------------------------------
echo.####正在转换 Windows 应用商店 ESD 映像为 WIM 映像##############################
echo.-------------------------------------------------------------------------------
echo.
echo.正在解密 Windows 应用商店 ESD 映像^(如果它已被加密^)……
attrib -r -h -s -a "%InstallEsd%" >nul
for /f "skip=1 tokens=4 delims=:." %%e in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" /Index:4 ^| find /i "Version"') do set ESDBuild=%%e
if "%ESDBuild%" equ "9600" %W81EsdDecrypter% "%InstallEsd%" 2>nul
if "%ESDBuild%" gtr "9600" %W10EsdDecrypter% "%InstallEsd%" >nul
echo.
:: 创建临时启动和安装映像
echo.正在创建临时容器映像……
call :RemoveFolder "%Temp%\ESD"
call :CreateFolder "%Temp%\ESD"
call :CaptureImage "%BootWim%", "%Temp%\ESD", "BootWim", "BootWim", "No" >nul

call :RemoveFolder "%Temp%\ESD"
call :CreateFolder "%Temp%\ESD"
call :CaptureImage "%InstallWim%", "%Temp%\ESD", "InstallWim", "InstallWim", "No" >nul
call :RemoveFolder "%Temp%\ESD"
echo.
echo.-------------------------------------------------------------------------------
echo.正在应用 Windows 应用商店 ESD 映像 [Install.esd，索引 ：1] 到 ^<Temp\DVD^>……
echo.-------------------------------------------------------------------------------
:: 创建 Windows 安装程序安装媒介文件夹“%Temp%\DVD”
call :RemoveFolder "%Temp%\DVD"
call :CreateFolder "%Temp%\DVD"
call :ApplyImage "%InstallEsd%", 1, "%Temp%\DVD"
move /y "%DVD%\sources\*.wim" "%Temp%\DVD\sources" >nul
echo.-------------------------------------------------------------------------------
echo.正在导出 Windows 应用商店 ESD 映像 [Install.esd，索引 ：2] 为启动映像……
echo.-------------------------------------------------------------------------------
call :ExportImageIndex "%InstallEsd%", 2, "%Temp%\DVD\sources\boot.wim", "WIM", "Yes"
call :DeleteImage "%Temp%\DVD\sources\boot.wim", 1 >nul
echo.-------------------------------------------------------------------------------
echo.正在导出 Windows 应用商店 ESD 映像 [Install.esd，索引 ：3] 为启动映像……
echo.-------------------------------------------------------------------------------
call :ExportImageIndex "%InstallEsd%", 3, "%Temp%\DVD\sources\boot.wim", "WIM", "Yes"

if "%ESDBuild%" equ "9600" (
	echo.-------------------------------------------------------------------------------
	echo.正在导出 Windows 应用商店 ESD 映像 [Install.esd，索引 ：4] 为安装映像……
	echo.-------------------------------------------------------------------------------
	call :ExportImageIndex "%InstallEsd%", 4, "%Temp%\DVD\sources\install.wim", "WIM", "No"
)

if "%ESDBuild%" gtr "9600" (
	if "%ESDImageIndex%" neq "*" (
		echo.-------------------------------------------------------------------------------
		echo.正在导出 Windows 应用商店 ESD 映像 [Install.esd，索引 ：%ESDImageIndex%] 为安装映像……
		echo.-------------------------------------------------------------------------------
		call :ExportImageIndex "%InstallEsd%", %ESDImageIndex%, "%Temp%\DVD\sources\install.wim", "WIM", "No"
	) else (
		for /l %%i in (3, 1, %ESDImageCount%) do (
			echo.-------------------------------------------------------------------------------
			echo.正在导出 Windows 应用商店 ESD 映像 [Install.esd，索引 ：%%i] 为安装映像……
			echo.-------------------------------------------------------------------------------
			call :ExportImageIndex "%InstallEsd%", %%i, "%Temp%\DVD\sources\install.wim", "WIM", "No"
		)
	)
)

:: 删除第一个空索引
call :DeleteImage "%Temp%\DVD\sources\install.wim", 1 >nul

:: 将 ESD 移动到 WIM 转换文件夹 <Temp\DVD> 至 <DVD> 的 Source 文件夹
call :RemoveFolder "%DVD%"
move /y "%Temp%\DVD" "%ROOT%" >nul

echo.-------------------------------------------------------------------------------
echo.####正在复制 EI.CFG 信息文件到 Source ^<DVD\sources^> 文件夹#####################
echo.-------------------------------------------------------------------------------
echo.
:: 获取安装映像索引版本
call :GetImageEdition "%InstallWim%", 1

:: 写入 EI.cfg 信息文件到 <DVD\sources> 文件夹
echo.正在复制 EI.CFG 文件到 ^<DVD\sources^> 文件夹……
if exist "%DVD%\sources\EI.CFG" del /f /q "%DVD%\sources\EI.CFG" >nul
(
	echo.[EditionID]
	if "%ESDImageIndex%" neq "*" echo.%ImageEdition%
	if "%ESDImageIndex%" equ "*" echo.
	echo.
	echo.[Channel]
	echo.Retail
	echo.
	echo.[VL]
	echo.0
	echo.
)>"%DVD%\sources\EI.CFG"

:: 从 Source 文件夹清理不需要的文件
call :RemoveFile "%DVD%\MediaMeta.xml"
echo.
echo.-------------------------------------------------------------------------------
echo.####转换 Windows 应用商店 ESD 映像为 WIM 映像已完成############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set ESDBuild=
set ESDImageCount=
set ESDImageIndex=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 转换 Windows ESD 映像为 WIM 映像
::-------------------------------------------------------------------------------------------
:ConvertEsd2Wim

setlocal

set ESDImageIndex=
set ESDImageCount=

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 转换 Windows ESD 映像为 WIM 映像
echo.===============================================================================
echo.

:: 检查 Windows 源启动映像是否存在
if not exist "%BootWim%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Boot.wim”映像……
	echo.
	echo.请将 Windows 安装程序中的“Boot.wim”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源安装 ESD 映像是否存在
if not exist "%InstallEsd%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Install.esd”映像……
	echo.
	echo.请将 Windows 安装程序中的“Install.esd”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

:: 查找当前 ESD 映像中的总索引数量
for /f "tokens=2 delims=: " %%i in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" ^| findstr /i Index') do (set ESDImageCount=%%i)

echo.-------------------------------------------------------------------------------
echo.####正在开始转换 Windows ESD 映像为 WIM 映像###################################
echo.-------------------------------------------------------------------------------
echo.
echo.正在读取 Windows ESD 映像信息……
echo.
echo.===============================================================================
echo.^|索引    ^|体系结构    ^|名称
echo.===============================================================================
for /f "tokens=2 delims=: " %%a in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" ^| findstr /i Index') do (
	for /f "tokens=2 delims=:" %%b in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" /Index:%%a ^| findstr /i Architecture') do (
		for /f "tokens=2 delims=:  " %%c in ('%DISM% /Get-WimInfo /WimFile:"%InstallEsd%" /Index:%%a ^| findstr /i Name') do (
			if %%a leq 9 echo.^|%%a       ^|%%b          ^|%%c
			if %%a gtr 9 echo.^|%%a      ^|%%b          ^|%%c
		)
	)
)
echo.===============================================================================
echo.
if "%ESDImageCount%" equ "1" ( 
	set /p ESDImageIndex=请输入 ESD 映像索引编号 # ：
) else set /p ESDImageIndex=请输入 ESD 映像索引编号的 # [范围 ：1-%ESDImageCount%，* - 全部] ：

if "%ESDImageIndex%" neq "*" if "%ESDImageIndex%" lss "1" (
	echo. 
	echo.输入的索引编号无效，有效范围为 [1-%ESDImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :ConvertEsd2Wim
)

if "%ESDImageIndex%" neq "*" if "%ESDImageIndex%" gtr %ESDImageCount% (
	echo. 
	echo.输入的索引编号无效，有效范围为 [1-%ESDImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :ConvertEsd2Wim
)
echo.
echo.-------------------------------------------------------------------------------
echo.####正在转换 Windows ESD 映像为 WIM 映像#######################################
echo.-------------------------------------------------------------------------------

:: 创建临时启动和安装映像
call :RemoveFolder "%Temp%\ESD"
call :CreateFolder "%Temp%\ESD"

call :CaptureImage "%InstallWim%", "%Temp%\ESD", "InstallWim", "InstallWim", "No" >nul
call :RemoveFolder "%Temp%\ESD"

:: 转换 Windows ESD 映像为 WIM 映像
if "%ESDImageIndex%" equ "*" call :ExportImage "%InstallEsd%", "%InstallWim%", "WIM", "No"	
if "%ESDImageIndex%" neq "*" call :ExportImageIndex "%InstallEsd%", %ESDImageIndex%, "%InstallWim%", "WIM", "No"

:: 删除已转换的 Windows 映像中的空索引索引 1
call :DeleteImage "%InstallWim%", 1 >nul

:: 删除原始 Windows ESD 映像
call :RemoveFile "%InstallEsd%"

echo.-------------------------------------------------------------------------------
echo.####转换 Windows ESD 映像为 WIM 映像已完成#####################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set ESDImageIndex=
set ESDImageCount=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 转换 Windows 媒介创建工具映像为 WIM 映像
::-------------------------------------------------------------------------------------------
:ConvertMCT2Wim

setlocal

cls
echo.===============================================================================
echo.            MSMG 工具箱 - 转换 Windows 媒介创建工具映像为 WIM 映像
echo.===============================================================================
echo.

:: 检查 Windows 源启动映像是否存在
if not exist "%BootWim%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Boot.wim”映像……
	echo.
	echo.请将 Windows 安装程序中的“Boot.wim”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源安装映像是否存在
if not exist "%InstallEsd%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Install.esd”映像……
	echo.
	echo.请将 Windows 安装程序中的“Install.esd”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始转换 Windows 媒介创建工具映像为 WIM 映像###########################
echo.-------------------------------------------------------------------------------

:: 将 Microsoft Windows 媒介创建工具已创建的 Install.wim 导出为新映像
call :ExportImageIndex "%InstallEsd%", 1, "%DVD%\sources\install1.wim", "WIM", "No"

:: 删除 Microsoft 媒介创建工具创建的 Install.wim
call :RemoveFile "%InstallEsd%"

:: 将新创建的映像重命名为 Install.wim
move /y "%DVD%\sources\install1.wim" %InstallWim% >nul

echo.-------------------------------------------------------------------------------
echo.####转换 Windows 媒介创建工具映像为 WIM 映像已完成#############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 转换源 WIM 映像为 ESD 映像
::-------------------------------------------------------------------------------------------
:ConvertWim2ESD

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 转换源 WIM 映像为 ESD 映像
echo.===============================================================================
echo.

:: 检查 Windows 源启动映像是否存在
if not exist "%BootWim%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Boot.wim”映像……
	echo.
	echo.请将 Windows 安装程序中的“Boot.wim”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源安装映像是否存在
if not exist "%InstallWim%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Install.wim”映像……
	echo.
	echo.请将 Windows 安装程序中的“Install.wim”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始转换源 WIM 映像为 ESD 映像#########################################
echo.-------------------------------------------------------------------------------

:: 获取映像索引号以维护
call :GetImageIndexNo "%InstallWim%"

if "%ImageIndexNo%" neq "*" if "%ImageIndexNo%" lss "1" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :SelectSourceDVD
)

if "%ImageIndexNo%" neq "*" if "%ImageIndexNo%" gtr %ImageCount% (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :SelectSourceDVD
)
echo.
echo.-------------------------------------------------------------------------------
echo.####正在转换源 WIM 映像为 ESD 映像#############################################
echo.-------------------------------------------------------------------------------

:: 导出源映像为 ESD 映像
if "%ImageIndexNo%" equ "*" call :ExportImage "%InstallWim%", "%InstallEsd%", "ESD", "No"
if "%ImageIndexNo%" neq "*" call :ExportImageIndex "%InstallWim%", %ImageIndexNo%, "%InstallEsd%", "ESD", "No"

:: 删除源映像文件
call :RemoveFile "%InstallWim%"

echo.-------------------------------------------------------------------------------
echo.####转换源 WIM 映像为 ESD 映像已完成###########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 语言包功能
::-------------------------------------------------------------------------------------------
:IntLanguagePacks

if "%IsDialogsEnabled%" equ "Yes" (
	cls
	echo.===============================================================================
	echo.                      MSMG 工具箱 - 集成 Windows 语言包
	echo.===============================================================================
	echo.
	echo.
	echo.
	echo.                                警         告
	echo.                                =============
	echo.
	echo.   请不要在集成更新之后集成语言包。如果你在集成语言包之前集成了包含与语言相关
	echo.   的资源的任何更新 ^(包括热修复程序、一般发行版内核更新 [GDR]、零日修补程序 
	echo.   [ZDP] 或服务包 [SP] ^)，则在其中包含的特定于语言的更改将不会被应用到更新中，
	echo.   你将不得不重新集成更新。请始终在集成更新之前集成语言包。
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.   若要关闭此警告对话框，请在工具 -^> 选项菜单中选择禁用对话框
	echo.
	echo.===============================================================================
	echo.
	choice /C:YN /N /M "你想要继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :IntegrateMenu
)

setlocal

set LanguagePackType=
set LanguagePackCode=

cls
echo.===============================================================================
echo.                    MSMG 工具箱 - 集成 Windows 语言包菜单
echo.===============================================================================
echo.
echo.  [1]   集成到 Windows 安装程序启动映像
echo.
echo.  [2]   集成到 Windows 安装映像
echo.
echo.  [3]   集成到 Windows 恢复映像
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:123X /N /M "请输入你的选项 ："
if errorlevel 4 goto :IntegrateMenu
if errorlevel 3 set LanguagePackType=Recovery
if errorlevel 2 set LanguagePackType=Install
if errorlevel 1 set LanguagePackType=Boot

cls
echo.===============================================================================
echo.                    MSMG 工具箱 - 集成 Windows 语言包菜单
echo.===============================================================================
echo.
if "%LanguagePackType%" equ "Boot" if "%IsBootImageSelected%" equ "No" (
	echo.Windows 安装程序启动映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 安装程序启动映像……
	goto :Stop	
)

if "%LanguagePackType%" equ "Recovery" if "%IsRecoveryImageSelected%" equ "No" (
	echo.Windows 恢复映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 恢复映像……
	goto :Stop	
)

cls
echo.===============================================================================
echo.             MSMG 工具箱 - 集成 Windows 语言包菜单 - 选择语言菜单
echo.===============================================================================
if "%SelectedSourceOS%" equ "w7" (
	echo. 阿拉伯语 - 沙特阿拉伯    [ar-SA]    拉脱维亚语 - 拉脱维亚    [lv-LV]
	echo. 保加利亚语 - 保加利亚    [bg-BG]    立陶宛语 - 立陶宛        [lt-LT]
	echo. 中文 - 香港特别行政区    [zh-HK]    挪威语 - 挪威            [nb-NO]
	echo. 中文 - 简体              [zh-CN]    波兰语 - 波兰            [pl-PL]
	echo. 中文 - 台湾              [zh-TW]    葡萄牙语 - 巴西          [pt-BR]
	echo. 克罗地亚语 - 克罗地亚    [hr-HR]    葡萄牙语 - 葡萄牙        [pt-PT]
	echo. 捷克语 - 捷克共和国      [cs-CZ]    罗马尼亚语 - 罗马尼亚    [ro-RO]
	echo. 丹麦语 - 丹麦            [da-DK]    俄语 - 俄罗斯            [ru-RU]
	echo. 荷兰语 - 荷兰            [nl-NL]    塞尔维亚语 - 塞尔维亚    [sr-Latn-CS]
	echo. 英语 - 美国              [en-US]    斯洛伐克语 - 斯洛伐克    [sk-SK]
	echo. 爱沙尼亚语 - 爱沙尼亚    [et-EE]    斯洛文尼亚语 - 斯洛文尼亚[sl-SI]
	echo. 芬兰语 - 芬兰            [fi-FI]    西班牙语 - 西班牙        [es-ES]
	echo. 法语 - 法国              [fr-FR]    瑞典语 - 瑞典            [sv-SE]
	echo. 德语 - 德国              [de-DE]    泰语 - 泰国              [th-TH]
	echo. 希腊语 - 希腊            [el-GR]    土耳其语 - 土耳其        [tr-TR]
	echo. 希伯来语 - 以色列        [he-IL]    乌克兰语 - 乌克兰        [uk-UA]
	echo. 匈牙利语 - 匈牙利        [hu-HU]    
	echo. 意大利语 - 意大利        [it-IT]    
	echo. 日语 - 日本              [ja-JP]
	echo. 朝鲜语 - 韩国            [ko-KR]   [X] 返回
)

if "%SelectedSourceOS%" equ "w81" (
	echo. 阿拉伯语 - 沙特阿拉伯    [ar-SA]    朝鲜语 - 韩国            [ko-KR]
	echo. 保加利亚语 - 保加利亚    [bg-BG]    拉脱维亚语 - 拉脱维亚    [lv-LV]
	echo. 中文 - 香港特别行政区    [zh-HK]    立陶宛语 - 立陶宛        [lt-LT]
	echo. 中文 - 简体              [zh-CN]    挪威语 - 挪威            [nb-NO]
	echo. 中文 - 台湾              [zh-TW]    波兰语 - 波兰            [pl-PL]
	echo. 克罗地亚语 - 克罗地亚    [hr-HR]    葡萄牙语 - 巴西          [pt-BR]
	echo. 捷克语 - 捷克共和国      [cs-CZ]    葡萄牙语 - 葡萄牙        [pt-PT]
	echo. 丹麦语 - 丹麦            [da-DK]    罗马尼亚语 - 罗马尼亚    [ro-RO]
	echo. 荷兰语 - 荷兰            [nl-NL]    俄语 - 俄罗斯            [ru-RU]
	echo. 英语 - 英国              [en-GB]    塞尔维亚语 - 塞尔维亚    [sr-Latn-CS]
	echo. 英语 - 美国              [en-US]    斯洛伐克语 - 斯洛伐克    [sk-SK]
	echo. 爱沙尼亚语 - 爱沙尼亚    [et-EE]    斯洛文尼亚语 - 斯洛文尼亚[sl-SI]
	echo. 芬兰语 - 芬兰            [fi-FI]    西班牙语 - 西班牙        [es-ES]
	echo. 法语 - 法国              [fr-FR]    瑞典语 - 瑞典            [sv-SE]
	echo. 德语 - 德国              [de-DE]    泰语 - 泰国              [th-TH]
	echo. 希腊语 - 希腊            [el-GR]    土耳其语 - 土耳其        [tr-TR]
	echo. 希伯来语 - 以色列        [he-IL]    乌克兰语 - 乌克兰        [uk-UA]
	echo. 匈牙利语 - 匈牙利        [hu-HU]    
	echo. 意大利语 - 意大利        [it-IT]    
	echo. 日语 - 日本              [ja-JP]	  [X] 返回
)

if "%SelectedSourceOS%" equ "w10" (
	echo. 阿拉伯语 - 沙特阿拉伯    [ar-SA]    日语 - 日本              [ja-JP]
	echo. 保加利亚语 - 保加利亚    [bg-BG]    朝鲜语 - 韩国            [ko-KR]
	echo. 中文 - 香港特别行政区    [zh-HK]    拉脱维亚语 - 拉脱维亚    [lv-LV]
	echo. 中文 - 简体              [zh-CN]    立陶宛语 - 立陶宛        [lt-LT]
	echo. 中文 - 台湾              [zh-TW]    挪威语 - 挪威            [nb-NO]
	echo. 克罗地亚语 - 克罗地亚    [hr-HR]    波兰语 - 波兰            [pl-PL]
	echo. 捷克语 - 捷克共和国      [cs-CZ]    葡萄牙语 - 巴西          [pt-BR]
	echo. 丹麦语 - 丹麦            [da-DK]    葡萄牙语 - 葡萄牙        [pt-PT]
	echo. 荷兰语 - 荷兰            [nl-NL]    罗马尼亚语 - 罗马尼亚    [ro-RO]
	echo. 英语 - 英国              [en-GB]    俄语 - 俄罗斯            [ru-RU]
	echo. 英语 - 美国              [en-US]    塞尔维亚语 - 塞尔维亚    [sr-Latn-RS]
	echo. 爱沙尼亚语 - 爱沙尼亚    [et-EE]    斯洛伐克语 - 斯洛伐克    [sk-SK]
	echo. 芬兰语 - 芬兰            [fi-FI]    斯洛文尼亚语 - 斯洛文尼亚[sl-SI]
	echo. 法语 - 加拿大            [fr-CA]    西班牙语 - 墨西哥        [es-MX]
	echo. 法语 - 法国              [fr-FR]    西班牙语 - 西班牙        [es-ES]
	echo. 德语 - 德国              [de-DE]    瑞典语 - 瑞典            [sv-SE]
	echo. 希腊语 - 希腊            [el-GR]    泰语 - 泰国              [th-TH]
	echo. 希伯来语 - 以色列        [he-IL]    土耳其语 - 土耳其        [tr-TR]
	echo. 匈牙利语 - 匈牙利        [hu-HU]    乌克兰语 - 乌克兰        [uk-UA]
	echo. 意大利语 - 意大利        [it-IT]    [X] 返回
)
echo.===============================================================================
set /p LanguagePackCode=请输入语言代码，不含‘[’‘]’：

if /i "%LanguagePackCode%" equ "X" goto :IntegrateMenu

cls
echo.===============================================================================
if "%LanguagePackType%" equ "Boot" echo.         MSMG 工具箱 - 集成 Windows 语言包到 Windows 安装程序启动映像
if "%LanguagePackType%" equ "Install" echo.             MSMG 工具箱 - 集成 Windows 语言包到 Windows 安装映像
if "%LanguagePackType%" equ "Recovery" echo.             MSMG 工具箱 - 集成 Windows 语言包到 Windows 恢复映像
echo.===============================================================================
echo.
:: 获取源映像索引体系结构
if "%LanguagePackType%" equ "Boot" call :GetImageArchitecture "%BootWim%", 1 >nul
if "%LanguagePackType%" equ "Recovery" (
	if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallMount%\1\%WinReWim%", 1 >nul
	if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallMount%\%WinReWim%", 1 >nul
)
if "%LanguagePackType%" equ "Install" (
	if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
	if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul
)

:: 获取 Windows 语言包文件夹路径
if "%SelectedSourceOS%" neq "w10" set "LanguagePacks=%LanguagePacks%\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%"
if "%SelectedSourceOS%" equ "w10" set "LanguagePacks=%LanguagePacks%\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%"

:: 获取软件服务包内部版本号
if "%SelectedSourceOS%" equ "w7" set "PackageServicePackBuild=17514"
if "%SelectedSourceOS%" equ "w81" set "PackageServicePackBuild=16384"
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageBuild%" equ "10240" set "PackageServicePackBuild=16384"
	if "%ImageBuild%" equ "10586" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
	if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"
)

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm" set "PackageArchitecture=arm"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 检查 Windows PE 语言包文件夹是否是空的
if "%LanguagePackType%" equ "Boot" (
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType:~,6%" neq "Server" if not exist "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType:~,6%" equ "Server" if not exist "%LanguagePacks%\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if "%PackageArchitecture%" neq "arm" if not exist "%LanguagePacks%\WinPE-Rejuv-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Rejuv-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" neq "Server" if not exist "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" equ "Server" if not exist "%LanguagePacks%\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if "%PackageArchitecture%" neq "arm" if not exist "%LanguagePacks%\WinPE-StorageWMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-StorageWMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-ATBroker-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-ATBroker-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-AudioCore-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-AudioCore-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-AudioDrivers-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-AudioDrivers-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-Narrator-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Narrator-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageInstallationType:~,6%" neq "Server" if not exist "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageInstallationType:~,6%" equ "Server" if not exist "%LanguagePacks%\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if "%ImageBuild%" leq "17134" (
		for /d %%i in (de-DE, en-GB, en-IN, es-ES, es-MX, fr-CA, fr-FR, it-IT, ja-JP, ko-KR, pl-PL, pt-BR, pt-PT, ru-RU, zh-CN, zh-HK, zh-TW) do (
			if "%LanguagePackCode%" equ "%%i" if not exist "%LanguagePacks%\WinPE-Speech-TTS-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.Windows 语言包文件夹缺少以下文件……
				echo.
				echo."WinPE-Speech-TTS-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.
				echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
				goto :Stop
			)
		)
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-Speech-TTS-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Speech-TTS-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-SRH-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SRH-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
)

:: 检查 Windows 语言或语言功能包文件夹是否是空的
if "%LanguagePackType%" equ "Install" (
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" if not exist "%LanguagePacks%\Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Embedded" if not exist "%LanguagePacks%\Microsoft-Windows-Embedded-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-Embedded-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType:~,6%" equ "Server" if not exist "%LanguagePacks%\Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" neq "Server" if not exist "%LanguagePacks%\Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" equ "Server" if not exist "%LanguagePacks%\Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageInstallationType%" equ "Client" if not exist "%LanguagePacks%\Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageInstallationType:~,6%" equ "Server" if not exist "%LanguagePacks%\Microsoft-Windows-Server-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-Server-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
)

:: 检查 Windows PE 语言包文件夹是否是空的
if "%LanguagePackType%" equ "Recovery" (
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if not exist "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-Rejuv-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Rejuv-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)	
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)	
	if "%SelectedSourceOS%" equ "w81" if "%PackageArchitecture%" neq "arm" if "%ImageInstallationType:~,6%" neq "Server" if not exist "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" equ "Server" if not exist "%LanguagePacks%\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if "%PackageArchitecture%" neq "arm" if not exist "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-StorageWMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-StorageWMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17134" if not exist "%LanguagePacks%\WinPE-AppxPackaging-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-AppxPackaging-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)	
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-ATBroker-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-ATBroker-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-AudioCore-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-AudioCore-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-AudioDrivers-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-AudioDrivers-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-HTA-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-HTA-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-Narrator-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Narrator-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop	
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17134" if not exist "%LanguagePacks%\WinPE-OpcServices-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-OpcServices-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-Rejuv-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Rejuv-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if "%ImageBuild%" leq "17134" (
		for /d %%i in (de-DE, en-GB, en-IN, es-ES, es-MX, fr-CA, fr-FR, it-IT, ja-JP, ko-KR, pl-PL, pt-BR, pt-PT, ru-RU, zh-CN, zh-HK, zh-TW) do (
			if "%LanguagePackCode%" equ "%%i" if not exist "%LanguagePacks%\WinPE-Speech-TTS-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.Windows 语言包文件夹缺少以下文件……
				echo.
				echo."WinPE-Speech-TTS-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.
				echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
				goto :Stop
			)
		)
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-Speech-TTS-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-Speech-TTS-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if not exist "%LanguagePacks%\WinPE-SRH-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SRH-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-StorageWMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-StorageWMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "14393" if not exist "%LanguagePacks%\WinPE-WiFi-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WiFi-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w10" if not exist "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 语言包文件夹缺少以下文件……
		echo.
		echo."WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\LanguagePacks\%SelectedSourceOS%\10.0.%ImageBuild%\%ImageArchitecture%\%LanguagePackCode%^> 文件夹……
		goto :Stop
	)
)
echo.-------------------------------------------------------------------------------
if "%LanguagePackType%" equ "Boot" echo.####正在开始集成 Windows 语言包到 Windows 启动映像#############################
if "%LanguagePackType%" equ "Install" echo.####正在开始集成 Windows 语言包到 Windows 安装映像#############################
if "%LanguagePackType%" equ "Recovery" echo.####正在开始集成 Windows 语言包到 Windows 恢复映像#############################
echo.-------------------------------------------------------------------------------
echo.
if "%LanguagePackType%" equ "Boot" (
	echo.    映像文件名称             ：Boot.wim
	echo.    映像索引                 ：1, 2
	echo.    映像体系结构             ：%ImageArchitecture%
	echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
	echo.    映像默认语言             ：%ImageDefaultLanguage%	
)
if "%LanguagePackType%" equ "Install" (
	echo.    映像文件名称             ：Install.wim
	if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
	if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
	echo.    映像体系结构             ：%ImageArchitecture%
	echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
	if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
	echo.    映像默认语言             ：%ImageDefaultLanguage%
)
if "%LanguagePackType%" equ "Recovery" (
	echo.    映像文件名称             ：WinRE.wim
	echo.    映像索引                 ：1
	echo.    映像体系结构             ：%ImageArchitecture%
	echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
	echo.    映像默认语言             ：%ImageDefaultLanguage%	
)
echo.
echo.-------------------------------------------------------------------------------
if "%LanguagePackType%" equ "Boot" echo.####正在集成 Windows 语言包到 Windows 启动映像#################################
if "%LanguagePackType%" equ "Install" echo.####正在集成 Windows 语言包到 Windows 安装映像#################################
if "%LanguagePackType%" equ "Recovery" echo.####正在集成 Windows 语言包到 Windows 恢复映像#################################
echo.-------------------------------------------------------------------------------
echo.
if "%LanguagePackType%" equ "Boot" (
	for /L %%i in (1, 1, 2) do (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE 语言包 [%LanguagePackCode%] 到 Windows 启动映像……
		echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
		if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" (
			call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			if "%ImageBuild%" geq "15063" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WinPE - AT Broker [%LanguagePackCode%] 到 Windows 启动映像……
				echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
				call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-ATBroker-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WinPE - 音频核心 [%LanguagePackCode%] 到 Windows 启动映像……
				echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
				call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-AudioCore-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WinPE - 音频驱动 [%LanguagePackCode%] 到 Windows 启动映像……
				echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
				call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-AudioDrivers-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			)
		)	
		if "%SelectedSourceOS%" neq "w7" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 增强的存储包 [%LanguagePackCode%] 到 Windows 启动映像……
			echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
			if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
		if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 讲述人 [%LanguagePackCode%] 到 Windows 启动映像……
			echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
			call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-Narrator-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"				
		)
		if "%SelectedSourceOS%" equ "w81" if exist "%LanguagePacks%\WinPE-IbsProvider-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - IBS 支持包 [%LanguagePackCode%] 到 Windows 启动映像……
			echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
			call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-IbsProvider-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 脚本包 [%LanguagePackCode%] 到 Windows 启动映像……
		echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
		if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" neq "w7" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 安全启动包 [%LanguagePackCode%] 到 Windows 启动映像……
			echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
			if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
	)
	
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "18362" if not exist "%BootMount%\2\Windows\servicing\Packages\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 安装程序包到 Windows 启动映像……
		echo.--------------------------[Boot.wim，索引 ：2]---------------------------------
		call :AddPackage "%BootMount%\2", "%Patches%\WinPE\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WinPE - 安装程序包 [%LanguagePackCode%] 到 Windows 启动映像……
	echo.--------------------------[Boot.wim，索引 ：2]---------------------------------
	if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%ImageInstallationType:~,6%" neq "Server" (
		if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "18362" if not exist "%BootMount%\2\Windows\servicing\Packages\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 安装程序客户端包到 Windows 启动映像……
			echo.--------------------------[Boot.wim，索引 ：2]---------------------------------
			call :AddPackage "%BootMount%\2", "%Patches%\WinPE\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 安装程序客户端包 [%LanguagePackCode%] 到 Windows 启动映像……
		echo.--------------------------[Boot.wim，索引 ：2]---------------------------------
		if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
	if "%ImageInstallationType:~,6%" equ "Server" (
		if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "18362" if not exist "%BootMount%\2\Windows\servicing\Packages\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 安装程序服务器端包到 Windows 启动映像……
			echo.--------------------------[Boot.wim，索引 ：2]---------------------------------
			call :AddPackage "%BootMount%\2", "%Patches%\WinPE\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 安装程序服务器端包 [%LanguagePackCode%] 到 Windows 启动映像……
		echo.--------------------------[Boot.wim，索引 ：2]---------------------------------
		if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\2", "%LanguagePacks%\WinPE-Setup-Server-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)		
	for /L %%i in (1, 1, 2) do (
		if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if "%ImageBuild%" leq "17134" (
			for /d %%z in (de-DE, en-GB, en-IN, es-ES, es-MX, fr-CA, fr-FR, it-IT, ja-JP, ko-KR, pl-PL, pt-BR, pt-PT, ru-RU, zh-CN, zh-HK, zh-TW) do (
				if "%LanguagePackCode%" equ "%%z" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 WinPE - 语音、文本到语音转换 [%LanguagePackCode%] 到 Windows 启动映像……
					echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
					call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-Speech-TTS-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
				)
			)
		)
		if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 语音、文本到语音转换 [%LanguagePackCode%] 到 Windows 启动映像……
			echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
			call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-Speech-TTS-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - SRH [%LanguagePackCode%] 到 Windows 启动映像……
			echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
			call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-SRH-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - SRT 包 [%LanguagePackCode%] 到 Windows 启动映像……
		echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
		if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - WDS 包 [%LanguagePackCode%] 到 Windows 启动映像……
		echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
		if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - WMI 包 [%LanguagePackCode%] 到 Windows 启动映像……
		echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
		if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		for /d %%z in (ja-JP, ko-KR, zh-HK, zh-CN, zh-TW) do (
			if "%LanguagePackCode%" equ "%%z" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WinPE - 字体支持包 [%LanguagePackCode%] 到 Windows 启动映像……
				echo.------------------------------[Boot.wim，索引 ：%%i]-----------------------------
				if "%SelectedSourceOS%" equ "w7" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-FontSupport-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
				if "%SelectedSourceOS%" equ "w81" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-FontSupport-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
				if "%SelectedSourceOS%" equ "w10" call :AddPackage "%BootMount%\%%i", "%LanguagePacks%\WinPE-FontSupport-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			)
		)	
	)
	echo.-------------------------------------------------------------------------------
	echo.正在创建 Windows 安装程序语言信息文件 [Lang.ini]……
	echo.--------------------------[Boot.wim，索引 ：2]---------------------------------
	%DISM% /Image:"%BootMount%\2" /Gen-LangINI /Distribution:"%DVD%"
	echo.
	if "%SelectedSourceOS%" neq "w10" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 [%LanguagePackCode%] 本地化 Windows 安装资源到源 DVD 中……
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在将 Windows PE 语言包 [%LanguagePackCode%] 解压到临时文件夹……
		call :RemoveFolder "%Temp%\LanguagePack"
		call :CreateFolder "%Temp%\LanguagePack"
		if "%SelectedSourceOS%" equ "w7" expand "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
		if "%SelectedSourceOS%" equ "w81" expand "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
		echo.
		echo.正在复制本地化 Windows 安装程序资源到源 DVD 中……
		call :CreateFolder "%DVD%\sources\%LanguagePackCode%"
		if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" neq "Server" call :CreateFolder "%DVD%\sources\cli"
		if "%ImageArchitecture%" equ "x86" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		if "%SelectedSourceOS%" equ "w81" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-sxs\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\etwproviders\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%"
		if "%SelectedSourceOS%" equ "w81" call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		if "%SelectedSourceOS%" equ "w81" call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%"
		
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\*.*" "%DVD%\sources\%LanguagePackCode%" >nul
		if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" neq "Server" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\cli\*.*" "%DVD%\sources\cli" >nul
		if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		if "%SelectedSourceOS%" equ "w81" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\etwproviders\*.*" "%DVD%\sources\etwproviders\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul
		if "%SelectedSourceOS%" equ "w81" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		if "%SelectedSourceOS%" equ "w81" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		echo.
	)

	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" leq "15063" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 [%LanguagePackCode%] 本地化 Windows 安装资源到源 DVD 中……
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在将 Windows PE 语言包 [%LanguagePackCode%] 解压到临时文件夹……
		call :RemoveFolder "%Temp%\LanguagePack"
		call :CreateFolder "%Temp%\LanguagePack"
		if "%SelectedSourceOS%" equ "w10" expand "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
		echo.
		echo.正在复制本地化 Windows 安装程序资源到源 DVD 中……
		call :CreateFolder "%DVD%\sources\%LanguagePackCode%"
		if "%ImageBuild%" leq 10586 if "%ImageInstallationType:~,6%" neq "Server" call :CreateFolder "%DVD%\sources\cli\%LanguagePackCode%"
		if "%ImageArchitecture%" equ "x86" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-shmig-dl\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-sxs\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\etwproviders\%LanguagePackCode%"
		if "%ImageBuild%" neq "10240" if "%ImageBuild%" neq "10586" if "%ImageArchitecture%" equ "x64" call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%"
		
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\*.*" "%DVD%\sources\%LanguagePackCode%" >nul
		if "%ImageBuild%" leq 10586 if "%ImageInstallationType:~,6%" neq "Server" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\cli\*.*" "%DVD%\sources\cli\%LanguagePackCode%" >nul
		if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-shmig-dl\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-shmig-dl\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\etwproviders\*.*" "%DVD%\sources\etwproviders\%LanguagePackCode%" >nul
		if "%ImageBuild%" neq "10240" if "%ImageBuild%" neq "10586" if "%ImageArchitecture%" equ "x64" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-fabric-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-shmig\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		echo.
	)

	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "16299" if "%ImageBuild%" leq "17763" if "%LanguagePackCode%" neq "en-US" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 [%LanguagePackCode%] 本地化 Windows 安装资源到源 DVD 中……
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在将 Windows PE 语言包 [%LanguagePackCode%] 解压到临时文件夹……
		call :RemoveFolder "%Temp%\LanguagePack"
		call :CreateFolder "%Temp%\LanguagePack"
		if "%SelectedSourceOS%" equ "w10" expand "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
		echo.
		echo.正在复制本地化 Windows 安装程序资源到源 DVD 中……
		call :CreateFolder "%DVD%\sources\%LanguagePackCode%"
		if "%ImageBuild%" leq "17134" if "%ImageArchitecture%" equ "x86" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%"
		if "%ImageBuild%" leq "17134" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\etwproviders\%LanguagePackCode%"
		if "%ImageBuild%" equ "16299" if "%ImageArchitecture%" equ "x64" call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%"
		if "%ImageBuild%" leq "17134" call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%"
		
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\*.*" "%DVD%\sources\%LanguagePackCode%" >nul
		if "%ImageBuild%" leq "17134" if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
		if "%ImageBuild%" leq "17134" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\etwproviders\*.*" "%DVD%\sources\etwproviders\%LanguagePackCode%" >nul
		if "%ImageBuild%" equ "16299" if "%ImageArchitecture%" equ "x64" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-fabric-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-shmig\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%" >nul
		if "%ImageBuild%" leq "17134" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		echo.
	)

	echo.正在复制 Windows 安装程序语言信息文件到启动映像……
	copy /y "%DVD%\sources\lang.ini" "%BootMount%\2\sources\lang.ini" >nul
	echo.
)

if "%LanguagePackType%" equ "Install" (
	if "%ImageIndexNo%" equ "*" (
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 语言包……
			echo.-------------------------------------------------------------------------------
			if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Embedded" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-Embedded-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType:~,6%" equ "Server" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType%" equ "Client" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" equ "Server" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w10" (
				if "%ImageInstallationType%" equ "Client" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
				if "%ImageInstallationType:~,6%" equ "Server" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-Server-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
				if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 语言功能 - 基本包……
					echo.-------------------------------------------------------------------------------
					if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
					if "%ImageBuild%" geq "17763" (
						call :CreateFolder "%Temp%\LanguagePacks"
						copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
						call :AddPackage "%InstallMount%\%%i", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
					)
				)
				if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 语言功能 - 手写识别包……
					echo.-------------------------------------------------------------------------------
					if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
					if "%ImageBuild%" geq "17763" (
						call :CreateFolder "%Temp%\LanguagePacks"
						copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
						call :AddPackage "%InstallMount%\%%i", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
					)
				)
				if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 语言功能 - OCR 包……
					echo.-------------------------------------------------------------------------------
					if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
					if "%ImageBuild%" geq "17763" (
						call :CreateFolder "%Temp%\LanguagePacks"
						copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
						call :AddPackage "%InstallMount%\%%i", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
					)
				)
				if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 语言功能 - 文本到语音转换包……
					echo.-------------------------------------------------------------------------------
					if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
					if "%ImageBuild%" geq "17763" (
						call :CreateFolder "%Temp%\LanguagePacks"
						copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
						call :AddPackage "%InstallMount%\%%i", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
					)
				)
				if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 语言功能 - 语音包……
					echo.-------------------------------------------------------------------------------
					if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%\%%i", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
					if "%ImageBuild%" geq "17763" (
						call :CreateFolder "%Temp%\LanguagePacks"
						copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
						call :AddPackage "%InstallMount%\%%i", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
					)
				)
			)
			echo.-------------------------------------------------------------------------------
			echo.正在更新 Windows 安装语言信息文件 [Lang.ini]……
			echo.-------------------------------------------------------------------------------
			%DISM% /Image:"%InstallMount%\%%i" /Gen-LangINI /Distribution:"%DVD%"
			echo.
		)
	) else (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 语言包……
		echo.-------------------------------------------------------------------------------
		if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Embedded" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-Embedded-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType:~,6%" equ "Server" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType%" equ "Client" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" equ "Server" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" (
			if "%ImageInstallationType%" equ "Client" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			if "%ImageInstallationType:~,6%" equ "Server" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-Server-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 语言功能 - 基本包……
				echo.-------------------------------------------------------------------------------
				if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
				if "%ImageBuild%" geq "17763" (
					call :CreateFolder "%Temp%\LanguagePacks"
					copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
					call :AddPackage "%InstallMount%", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Basic-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
				)
			)
			if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 语言功能 - 手写识别包……
				echo.-------------------------------------------------------------------------------
				if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
				if "%ImageBuild%" geq "17763" (
					call :CreateFolder "%Temp%\LanguagePacks"
					copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
					call :AddPackage "%InstallMount%", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Handwriting-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
				)
			)
			if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 语言功能 - OCR 包……
				echo.-------------------------------------------------------------------------------
				if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
				if "%ImageBuild%" geq "17763" (
					call :CreateFolder "%Temp%\LanguagePacks"
					copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
					call :AddPackage "%InstallMount%", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-OCR-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
				)
			)
			if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 语言功能 - 文本到语音转换包……
				echo.-------------------------------------------------------------------------------
				if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
				if "%ImageBuild%" geq "17763" (
					call :CreateFolder "%Temp%\LanguagePacks"
					copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
					call :AddPackage "%InstallMount%", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-TextToSpeech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
				)
			)				
			if exist "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 语言功能 - 语音包……
				echo.-------------------------------------------------------------------------------
				if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%", "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
				if "%ImageBuild%" geq "17763" (
					call :CreateFolder "%Temp%\LanguagePacks"
					copy /y "%LanguagePacks%\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
					call :AddPackage "%InstallMount%", "%Temp%\LanguagePacks\Microsoft-Windows-LanguageFeatures-Speech-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
				)
			)
		)
		echo.-------------------------------------------------------------------------------
		echo.正在更新 Windows 安装语言信息文件 [Lang.ini]……
		echo.-------------------------------------------------------------------------------
		%DISM% /Image:"%InstallMount%" /Gen-LangINI /Distribution:"%DVD%"
		echo.
	)
	echo.-------------------------------------------------------------------------------
	echo.正在集成 [%LanguagePackCode%] 本地化 Windows 安装资源到源 DVD 中……
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在解压 Windows 语言包 [%LanguagePackCode%] 解压到临时文件夹……
	call :RemoveFolder "%Temp%\LanguagePack"
	call :CreateFolder "%Temp%\LanguagePack"
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" expand "%LanguagePacks%\Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Embedded" expand "%LanguagePacks%\Microsoft-Windows-Embedded-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType:~,6%" equ "Server" expand "%LanguagePacks%\Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
	if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType%" equ "Client" expand "%LanguagePacks%\Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
	if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" equ "Server" expand "%LanguagePacks%\Microsoft-Windows-Server-Refresh-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
	if "%SelectedSourceOS%" equ "w10" if "%ImageInstallationType%" equ "Client" expand "%LanguagePacks%\Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
	if "%SelectedSourceOS%" equ "w10" if "%ImageInstallationType:~,6%" equ "Server" expand "%LanguagePacks%\Microsoft-Windows-Server-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" -f:* "%Temp%\LanguagePack" >nul
	echo.
	echo.正在复制本地化 Windows 安装程序资源到源 DVD 中……
	call :CreateFolder "%DVD%\sources\%LanguagePackCode%"

	if "%SelectedSourceOS%" equ "w7" (
		if "%ImageArchitecture%" equ "x86" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\etwproviders\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"

		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\*.*" "%DVD%\sources\%LanguagePackCode%" >nul
		if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\etwproviders\*.*" "%DVD%\sources\etwproviders\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul

		if "%ImageInstallationType%" neq "Embedded" (
			call :CreateFolder "%DVD%\sources\sp1\%LanguagePackCode%"
			call :CreateFolder "%DVD%\sources\sp1\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%"
			call :CreateFolder "%DVD%\sources\sp1\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
			call :CreateFolder "%DVD%\sources\sp1\etwproviders\%LanguagePackCode%"
			call :CreateFolder "%DVD%\sources\sp1\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%"

			xcopy /y "%Temp%\LanguagePack\sp1\setup\sources\%LanguagePackCode%\*.*" "%DVD%\sources\sp1\%LanguagePackCode%" >nul
			if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\sp1\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\sp1\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\sp1\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\sp1\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\sp1\setup\sources\%LanguagePackCode%\etwproviders\*.*" "%DVD%\sources\sp1\etwproviders\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\sp1\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\sp1\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul

			echo.正在将本地化 Windows 安装许可文件复制到源 DVD 中……
			call :CreateFolder "%DVD%\sources\license\%LanguagePackCode%"
			call :CreateFolder "%DVD%\sources\sp1\license\%LanguagePackCode%"
			xcopy /y "%Temp%\LanguagePack\sources\license\%LanguagePackCode%\*.*" "%DVD%\sources\license\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\sp1\sources\license\%LanguagePackCode%\*.*" "%DVD%\sources\sp1\license\%LanguagePackCode%" >nul
		)
	)

	if "%SelectedSourceOS%" equ "w81" (
		if "%ImageInstallationType:~,6%" neq "Server" call :CreateFolder "%DVD%\sources\cli\%LanguagePackCode%"
		if "%ImageArchitecture%" equ "x86" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-sxs\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\etwproviders\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%"

		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\*.*" "%DVD%\sources\%LanguagePackCode%" >nul
		if "%ImageInstallationType:~,6%" neq "Server" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\cli\*.*" "%DVD%\sources\cli\%LanguagePackCode%" >nul
		if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\etwproviders\*.*" "%DVD%\sources\etwproviders\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
	)

	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" leq "15063" (
		if "%ImageBuild%" leq "10586" if "%ImageInstallationType:~,6%" neq "Server" call :CreateFolder "%DVD%\sources\cli\%LanguagePackCode%"
		if "%ImageArchitecture%" equ "x86" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-shmig-dl\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-sxs\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\etwproviders\%LanguagePackCode%"
		if "%ImageBuild%" neq "10240" if "%ImageBuild%" neq "10586" if "%ImageArchitecture%" equ "x64" call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%"

		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\*.*" "%DVD%\sources\%LanguagePackCode%" >nul
		if "%ImageBuild%" leq "10586" if "%ImageInstallationType:~,6%" neq "Server" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\cli\*.*" "%DVD%\sources\cli\%LanguagePackCode%" >nul
		if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-shmig-dl\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-shmig-dl\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\etwproviders\*.*" "%DVD%\sources\etwproviders\%LanguagePackCode%" >nul
		if "%ImageBuild%" neq "10240" if "%ImageBuild%" neq "10586" if "%ImageArchitecture%" equ "x64" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-fabric-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-shmig\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
		xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
	)
	
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "16299" if "%ImageBuild%" leq "18363" (
		if "%ImageArchitecture%" equ "x86" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%"
		if "%ImageBuild%" leq "17134" call :CreateFolder "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\etwproviders\%LanguagePackCode%"
		if "%ImageBuild%" equ "16299" if "%ImageArchitecture%" equ "x64" call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%"
		if "%ImageBuild%" leq "17134" call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%"
		call :CreateFolder "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%"

		if "%LanguagePackCode%" neq "en-US" (
			xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\*.*" "%DVD%\sources\%LanguagePackCode%" >nul
			if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
			if "%ImageBuild%" leq "17134" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\etwproviders\*.*" "%DVD%\sources\etwproviders\%LanguagePackCode%" >nul
			if "%ImageBuild%" equ "16299" if "%ImageArchitecture%" equ "x64" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-fabric-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-shmig\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%" >nul
			if "%ImageBuild%" leq "17134" xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\setup\sources\%LanguagePackCode%\replacementmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		)

		if "%LanguagePackCode%" equ "en-US" (
			xcopy /y "%Temp%\LanguagePack\setup\sources\*.*" "%DVD%\sources\%LanguagePackCode%" >nul
			if "%ImageArchitecture%" equ "x86" xcopy /y "%Temp%\LanguagePack\setup\sources\dlmanifests\microsoft-windows-iasserver-migplugin\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-iasserver-migplugin\%LanguagePackCode%" >nul
			if "%ImageBuild%" leq "17134" xcopy /y "%Temp%\LanguagePack\setup\sources\dlmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\dlmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\setup\sources\etwproviders\*.*" "%DVD%\sources\etwproviders\%LanguagePackCode%" >nul
			if "%ImageBuild%" equ "16299" if "%ImageArchitecture%" equ "x64" xcopy /y "%Temp%\LanguagePack\setup\sources\replacementmanifests\microsoft-windows-fabric-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-fabric-core\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\setup\sources\replacementmanifests\microsoft-windows-offlinefiles-core\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-offlinefiles-core\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\setup\sources\replacementmanifests\microsoft-windows-shmig\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-shmig\%LanguagePackCode%" >nul
			if "%ImageBuild%" leq "17134" xcopy /y "%Temp%\LanguagePack\setup\sources\replacementmanifests\microsoft-windows-storagemigration\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-storagemigration\%LanguagePackCode%" >nul
			xcopy /y "%Temp%\LanguagePack\setup\sources\replacementmanifests\microsoft-windows-sxs\*.*" "%DVD%\sources\replacementmanifests\microsoft-windows-sxs\%LanguagePackCode%" >nul
		)
	)
	echo.
)

if "%LanguagePackType%" equ "Recovery" (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WinPE 语言包 [%LanguagePackCode%] 到 Windows 恢复映像……
	echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
	if "%SelectedSourceOS%" equ "w7" call :AddPackage "%WinReMount%", "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w10" (
		call :AddPackage "%WinReMount%", "%LanguagePacks%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		if "%ImageBuild%" geq "17134" (
			if exist "%LanguagePacks%\Microsoft-Windows-WinPE-AppxPackaging-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WinPE - Appx 打包 [%LanguagePackCode%] 到 Windows 恢复映像……
				echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
				call :AddPackage "%WinReMount%", "%LanguagePacks%\Microsoft-Windows-WinPE-AppxPackaging-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			)
			if exist "%LanguagePacks%\Microsoft-Windows-WinPE-OpcServices-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WinPE - Opc 服务 [%LanguagePackCode%] 到 Windows 恢复映像……
				echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
				call :AddPackage "%WinReMount%", "%LanguagePacks%\Microsoft-Windows-WinPE-OpcServices-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - Appx 打包 [%LanguagePackCode%] 到 Windows 恢复映像……
			echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
			call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-AppxPackaging-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
		if "%ImageBuild%" geq "15063" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - AT Broker [%LanguagePackCode%] 到 Windows 恢复映像……
			echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
			call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-ATBroker-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 音频核心 [%LanguagePackCode%] 到 Windows 恢复映像……
			echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
			call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-AudioCore-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 音频驱动 [%LanguagePackCode%] 到 Windows 恢复映像……
			echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
			call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-AudioDrivers-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
	)
	if "%SelectedSourceOS%" neq "w7" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 增强的存储包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-EnhancedStorage-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
	if "%SelectedSourceOS%" equ "w81" if exist "%LanguagePacks%\WinPE-IbsProvider-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - IBS 支持包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-IbsProvider-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
	)
	if "%SelectedSourceOS%" equ "w10" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - HTA 包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-HTA-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		if "%ImageBuild%" geq "15063" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 讲述人 [%LanguagePackCode%] 到 Windows 恢复映像……
			echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
			call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Narrator-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"				
		)
		if "%ImageBuild%" geq "17134" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - Opc 服务 [%LanguagePackCode%] 到 Windows 恢复映像……
			echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
			call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-OpcServices-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)		
	)
	if "%SelectedSourceOS%" neq "w7" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - Rejuv 包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Rejuv-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Rejuv-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WinPE - 脚本包 [%LanguagePackCode%] 到 Windows 恢复映像……
	echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
	if "%SelectedSourceOS%" equ "w7" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Scripting-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" neq "w7" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 安全启动包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-SecureStartup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
	if "%SelectedSourceOS%" equ "w7" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 安装程序包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Setup-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 安装程序客户端包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Setup-Client-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" if "%ImageBuild%" leq "17134" (
		for /d %%z in (de-DE, en-GB, en-IN, es-ES, es-MX, fr-CA, fr-FR, it-IT, ja-JP, ko-KR, pl-PL, pt-BR, pt-PT, ru-RU, zh-CN, zh-HK, zh-TW) do (
			if "%LanguagePackCode%" equ "%%z" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WinPE - 语音、文本到语音转换 [%LanguagePackCode%] 到 Windows 恢复映像……
				echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
				call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Speech-TTS-%LanguagePackCode%-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
			)
		)
	)
	if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "15063" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - 语音、文本到语音转换 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-Speech-TTS-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - SRH [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-SRH-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WinPE - SRT 包 [%LanguagePackCode%] 到 Windows 恢复映像……
	echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
	if "%SelectedSourceOS%" equ "w7" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-SRT-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" neq "w7" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - Storage WMI 包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-StorageWMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
		if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-StorageWMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WinPE - WDS 包 [%LanguagePackCode%] 到 Windows 恢复映像……
	echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
	if "%SelectedSourceOS%" equ "w7" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-WDS-Tools-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w10" if exist "%LanguagePacks%\WinPE-WiFi-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WinPE - WiFi 包 [%LanguagePackCode%] 到 Windows 恢复映像……
		echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
		call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-WiFi-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)			
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WinPE - WMI 包 [%LanguagePackCode%] 到 Windows 恢复映像……
	echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
	if "%SelectedSourceOS%" equ "w7" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
	if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-WMI-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
	for /d %%z in (ja-JP, ko-KR, zh-HK, zh-CN, zh-TW) do (
		if "%LanguagePackCode%" equ "%%z" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WinPE - 字体支持包 [%LanguagePackCode%] 到 Windows 恢复映像……
			echo.--------------------------[WinRE.wim，索引 ：1]--------------------------------
			if "%SelectedSourceOS%" equ "w7" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-FontSupport-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.1.7601.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w81" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-FontSupport-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~6.3.9600.%PackageServicePackBuild%.cab"
			if "%SelectedSourceOS%" equ "w10" call :AddPackage "%WinReMount%", "%LanguagePacks%\WinPE-FontSupport-Package~31bf3856ad364e35~%PackageArchitecture%~%LanguagePackCode%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
	)
)

if "%IsLogsEnabled%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	echo.####正在生成 Windows 语言包集成日志文件########################################
	echo.-------------------------------------------------------------------------------
	echo.
	if "%LanguagePackType%" equ "Boot" (
		for /l %%i in (1, 1, 2) do (
			echo.Windows 语言包 [Boot.wim，索引 ：%%i] 集成日志……
			call :GetPackages "%BootMount%\%%i", "Boot-%%i.txt"
			echo.
		)
	)
	if "%LanguagePackType%" equ "Install" (
		if "%ImageIndexNo%" equ "*" (
			echo.Windows 语言包 [Install.wim，索引 ：1-%ImageCount%] 集成日志……
			for /L %%i in (1, 1, %ImageCount%) do (
				call :GetPackages "%InstallMount%\%%i", "LanguagePacks_Install-%%i.txt"
				echo.
			)
		) else (
			echo.Windows 语言包 [Install.wim，索引 ：%ImageIndexNo%] 集成日志……
			call :GetPackages "%InstallMount%", "LanguagePacks_Install.txt"
			echo.
		)
	)
	if "%LanguagePackType%" equ "Recovery" (
		echo.Windows 语言包 [WinRE.wim，索引 ：1] 集成日志……
		call :GetPackages "%WinReMount%", "LanguagePacks_Install_WinRE.txt"
		echo.
	)
)
echo.-------------------------------------------------------------------------------
echo.####正在清理临时文件和文件夹###################################################
echo.-------------------------------------------------------------------------------
echo.
echo.正在清理临时文件夹……
call :RemoveFolder "%Temp%\LanguagePack"
echo.
echo.-------------------------------------------------------------------------------
if "%LanguagePackType%" equ "Boot" echo.####集成 Windows 语言包到 Windows 启动映像已完成###############################
if "%LanguagePackType%" equ "Install" echo.####集成 Windows 语言包到 Windows 安装映像已完成###############################
if "%LanguagePackType%" equ "Recovery" echo.####集成 Windows 语言包到 Windows 恢复映像已完成###############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set LanguagePacks=
set LanguagePackType=
set LanguagePackCode=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 驱动模块
::-------------------------------------------------------------------------------------------
:IntDrivers

setlocal

set DriverType=

cls
echo.===============================================================================
echo.                     MSMG 工具箱 - 集成 Windows 驱动菜单
echo.===============================================================================
echo.
echo.  [1]   集成到 Windows 安装程序启动映像
echo.
echo.  [2]   集成到 Windows 安装映像
echo.
echo.  [3]   集成到 Windows 恢复映像
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:123X /N /M "请输入你的选项 ："
if errorlevel 4 goto :IntegrateMenu
if errorlevel 3 set DriverType=Recovery
if errorlevel 2 set DriverType=Install
if errorlevel 1 set DriverType=Boot

cls
echo.===============================================================================
if "%DriverType%" equ "Boot" echo.          MSMG 工具箱 - 集成 Windows 驱动到 Windows 安装程序启动映像
if "%DriverType%" equ "Install" echo.              MSMG 工具箱 - 集成 Windows 驱动到 Windows 安装映像
if "%DriverType%" equ "Recovery" echo.              MSMG 工具箱 - 集成 Windows 驱动到 Windows 恢复映像
echo.===============================================================================
echo.
if "%DriverType%" equ "Boot" if "%IsBootImageSelected%" equ "No" (
	echo.Windows 安装程序启动映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 安装程序启动映像……
	goto :Stop	
)

if "%DriverType%" equ "Recovery" if "%IsRecoveryImageSelected%" equ "No" (
	echo.Windows 恢复映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 恢复映像……
	goto :Stop	
)

:: 获取源映像索引体系结构
if "%DriverType%" equ "Boot" call :GetImageArchitecture "%BootWim%", 1 >nul
if "%DriverType%" equ "Recovery" (
	if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallMount%\1\%WinReWim%", 1 >nul
	if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallMount%\%WinReWim%", 1 >nul
)
if "%DriverType%" equ "Install" (
	if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
	if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul
)

:: 设置 Windows 驱动文件夹路径
if "%DriverType%" equ "Boot" set "Drivers=%Drivers%\WinPE\%SelectedSourceOS%\%ImageArchitecture%"
if "%DriverType%" equ "Install" set "Drivers=%Drivers%\Install\%SelectedSourceOS%\%ImageArchitecture%"
if "%DriverType%" equ "Recovery" set "Drivers=%Drivers%\WinPE\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查 Windows 驱动文件夹是否是空的
for /f %%i in ('dir /b /s /a:-d "%Drivers%\*.*" 2^>nul ^| find /v /c ""') do (
	if "%%i" equ "0" (
		if "%DriverType%" equ "Boot" echo.Windows 驱动文件夹 ^<Drivers\WinPE\%SelectedSourceOS%\%ImageArchitecture%^> 是空的……
		if "%DriverType%" equ "Install" echo.Windows 驱动文件夹 ^<Drivers\Install\%SelectedSourceOS%\%ImageArchitecture%^> 是空的……
		if "%DriverType%" equ "Recovery" echo.Windows 驱动文件夹 ^<Drivers\WinPE\%SelectedSourceOS%\%ImageArchitecture%^> 是空的……
		echo.
		echo.请复制 Windows 驱动文件到相应的文件夹……
		goto :Stop
	)
)
echo.-------------------------------------------------------------------------------
if "%DriverType%" equ "Boot" echo.####正在开始集成 Windows 驱动到 Windows 启动映像###############################
if "%DriverType%" equ "Install" echo.####正在开始集成 Windows 驱动到 Windows 安装映像###############################
if "%DriverType%" equ "Recovery" echo.####正在开始集成 Windows 驱动到 Windows 恢复映像###############################
echo.-------------------------------------------------------------------------------
echo.
if "%DriverType%" equ "Boot" (
	echo.    映像文件名称             ：Boot.wim
	echo.    映像索引                 ：2
)
if "%DriverType%" equ "Install" (
	echo.    映像文件名称             ：Install.wim
	if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
	if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
)
if "%DriverType%" equ "Recovery" (
	echo.    映像文件名称             ：WinRE.wim
	echo.    映像索引                 ：1
)
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%DriverType%" equ "Boot" echo.####正在集成 Windows 驱动到 Windows 启动映像###################################
if "%DriverType%" equ "Install" echo.####正在集成 Windows 驱动到 Windows 安装映像###################################
if "%DriverType%" equ "Recovery" echo.####正在集成 Windows 驱动到 Windows 恢复映像###################################
echo.-------------------------------------------------------------------------------

if "%DriverType%" equ "Boot" call :AddDriver "%BootMount%\2", "%Drivers%"

if "%DriverType%" equ "Install" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			echo.-------------------------[Install.wim，索引 ：%%i]-------------------------------
			call :AddDriver "%InstallMount%\%%i", "%Drivers%"
		)
	) else (
		call :AddDriver "%InstallMount%", "%Drivers%"
	)
)

if "%DriverType%" equ "Recovery" call :AddDriver "%WinReMount%", "%Drivers%"

echo.-------------------------------------------------------------------------------
if "%DriverType%" equ "Boot" echo.####集成 Windows 驱动到 Windows 启动映像已完成###################################
if "%DriverType%" equ "Install" echo.####集成 Windows 驱动到 Windows 安装映像已完成###################################
if "%DriverType%" equ "Recovery" echo.####集成 Windows 驱动到 Windows 恢复映像已完成###################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Drivers=
set DriverType=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft .NET Framework 3.5 模块
::-------------------------------------------------------------------------------------------
:IntNetFX35

setlocal

set PackageArchitecture=

cls
echo.===============================================================================
echo.               MSMG 工具箱 - 集成 Microsoft .NET Framework 3.5
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包服务包内部版本
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageBuild%" equ "10240" set "PackageServicePackBuild=16384"
	if "%ImageBuild%" equ "10586" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
	if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"
)

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm" set "PackageArchitecture=arm"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 根据源映像体系结构设置 Microsoft .NET Framework 3.5 功能包文件夹路径
if exist "%DVD%\sources\sxs" (
	if "%SelectedSourceOS%" equ "w81" set "NetFX35=%DVD%\sources\sxs"
	if "%SelectedSourceOS%" equ "w10" (
		if "%ImageBuild%" leq "16299" set "NetFX35=%DVD%\sources\sxs\microsoft-windows-netfx3-ondemand-package.cab"
		if "%ImageBuild%" geq "17134" set "NetFX35=%DVD%\sources\sxs\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
	)
) else (
	if "%SelectedSourceOS%" equ "w81" set "NetFX35=%NetFX35%\%SelectedSourceOS%\%ImageArchitecture%"
	if "%SelectedSourceOS%" equ "w10" set "NetFX35=%NetFX35%\%SelectedSourceOS%\10.0.%ImageBuild%\Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
)

:: 检查 Microsoft .NET Framework 3.5 功能包文件夹是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%NetFX35%\msil_system.net_b03f5f7f11d50a3a_6.3.9600.16384_none_78f2900af99c8442\system.net.dll" (
	echo.Microsoft .NET Framework 3.5 包文件夹丢失或者是空的……
	echo.
	echo.请将文件复制到 ^<Packs\NetFX35\w81\%ImageArchitecture%^> 文件夹……
	echo.
	goto :Stop
)

:: 检查 Microsoft .NET Framework 3.5 功能包文件夹是否存在
if "%SelectedSourceOS%" equ "w10" if not exist %NetFX35% (
	echo.Microsoft .NET Framework 3.5 包文件丢失……
	echo.
	if "%ImageBuild%" leq "16299" echo.请从源 DVD 中将文件“microsoft-windows-netfx3-ondemand-package.cab”复制到 ^<DVD\sources\sxs^> 文件夹
	if "%ImageBuild%" geq "17134" echo.请从源 DVD 中将文件“microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~%PackageArchitecture%~~.cab”复制到 ^<DVD\sources\sxs^> 文件夹
	echo.
	echo.或者复制以下工具箱适配包文件到 ^<Packs\NetFX35\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	echo.	
	echo."Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	goto :Stop
)

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%NetFX35%" neq "%DVD%\sources\sxs\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~%PackageArchitecture%~~.cab" if exist %NetFX35% (
	copy /y %NetFX35% "%Temp%\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
	set "NetFX35=%Temp%\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft .NET Framework 3.5##################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft .NET Framework 3.5######################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.正在检查 Microsoft .NET Framework 3.5 是否已启用……
		if "%SelectedSourceOS%" equ "w81" (
			%DISM% /Image:"%InstallMount%\%%i" /Get-FeatureInfo /FeatureName:NetFX3 | findstr /c:"State : Enable Pending" >nul
			if errorlevel 1 (
				echo.Microsoft .NET Framework 3.5 尚未启用……
				echo.
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft .NET Framework 3.5 软件包……
				echo.-------------------------------------------------------------------------------
				%DISM% /Image:"%InstallMount%\%%i" /Enable-Feature /All /LimitAccess /FeatureName:NetFX3 /Source:%NetFX35%
				echo.
				if "%IsLogsEnabled%" equ "Yes" (
					echo.-------------------------------------------------------------------------------
					echo.####正在生成 Microsoft .NET Framework 3.5 集成日志文件#########################
					echo.-------------------------------------------------------------------------------
					echo.
					echo.正在写入 Microsoft .NET Framework 3.5 集成日志文件……
					call :GetFeatures "%InstallMount%\%%i", "NetFX35-%%i.txt"
					echo.
				)
				if "%%i" equ "%ImageCount%" (
					echo.-------------------------------------------------------------------------------
					echo.####集成 Microsoft .NET Framework 3.5 已完成###################################
					echo.-------------------------------------------------------------------------------
					echo.
				)
			) else (
				echo.Microsoft .NET Framework 3.5 已被启用……
				echo.
				echo.正在跳过集成 Microsoft .NET Framework 3.5……
				if "%%i" equ "%ImageCount%" (
					echo.
					echo.-------------------------------------------------------------------------------
					echo.####集成 Microsoft .NET Framework 3.5 已停止###################################
					echo.-------------------------------------------------------------------------------
					echo.
				)
			)
		)
		if "%SelectedSourceOS%" equ "w10" (
			%DISM% /Image:"%InstallMount%\%%i" /Get-FeatureInfo /FeatureName:NetFx3 | findstr /c:"State : Enabled" >nul
			if errorlevel 1 (
				echo.Microsoft .NET Framework 3.5 尚未启用……
				echo.
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft .NET Framework 3.5 软件包……
				echo.-------------------------------------------------------------------------------
				%DISM% /Image:"%InstallMount%\%%i" /Add-Package:%NetFX35%
				echo.
			
				if "%IsLogsEnabled%" equ "Yes" (
					echo.-------------------------------------------------------------------------------
					echo.####正在生成 Microsoft .NET Framework 3.5 集成日志文件#########################
					echo.-------------------------------------------------------------------------------
					echo.
					echo.正在写入 Microsoft .NET Framework 3.5 集成日志文件……
					call :GetFeatures "%InstallMount%\%%i", "NetFX35-%%i.txt"
					echo.          
				)
				if "%%i" equ "%ImageCount%" (
					echo.-------------------------------------------------------------------------------
					echo.####集成 Microsoft .NET Framework 3.5 已完成###################################
					echo.-------------------------------------------------------------------------------
					echo.
				)
			) else (
				echo.Microsoft .NET Framework 3.5 已被启用……
				echo.
				echo.正在跳过集成 Microsoft .NET Framework 3.5……
				if "%%i" equ "%ImageCount%" (
					echo.
					echo.-------------------------------------------------------------------------------
					echo.####集成 Microsoft .NET Framework 3.5 已停止###################################
					echo.-------------------------------------------------------------------------------
					echo.
				)
			)
		)
	)
) else (
	echo.
	echo.正在检查 Microsoft .NET Framework 3.5 是否已启用……
	if "%SelectedSourceOS%" equ "w81" (
		%DISM% /Image:"%InstallMount%" /Get-FeatureInfo /FeatureName:NetFX3 | findstr /c:"State : Enable Pending" >nul
		if errorlevel 1 (
			echo.Microsoft .NET Framework 3.5 尚未启用……
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 3.5 软件包……
			echo.-------------------------------------------------------------------------------
			%DISM% /Image:"%InstallMount%" /Enable-Feature /All /LimitAccess /FeatureName:NetFX3 /Source:%NetFX35%
			echo.
			if "%IsLogsEnabled%" equ "Yes" (
				echo.-------------------------------------------------------------------------------
				echo.####正在生成 Microsoft .NET Framework 3.5 集成日志文件#########################
				echo.-------------------------------------------------------------------------------
				echo.
				echo.正在写入 Microsoft .NET Framework 3.5 集成日志文件……
				call :GetFeatures "%InstallMount%", "NetFX35.txt"
				echo.
			)
			echo.-------------------------------------------------------------------------------
			echo.####集成 Microsoft .NET Framework 3.5 已完成###################################
			echo.-------------------------------------------------------------------------------
			echo.
		) else (
			echo.Microsoft .NET Framework 3.5 已被启用……
			echo.
			echo.-------------------------------------------------------------------------------
			echo.####集成 Microsoft .NET Framework 3.5 已停止###################################
			echo.-------------------------------------------------------------------------------
			echo.
			goto :Stop
		)
	)
	if "%SelectedSourceOS%" equ "w10" (
		%DISM% /Image:"%InstallMount%" /Get-FeatureInfo /FeatureName:NetFx3 | findstr /c:"State : Enabled" >nul
		if errorlevel 1 (
			echo.Microsoft .NET Framework 3.5 尚未启用……
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 3.5 软件包……
			echo.-------------------------------------------------------------------------------
			%DISM% /Image:"%InstallMount%" /Add-Package:%NetFX35%
			echo.
			
			if "%IsLogsEnabled%" equ "Yes" (
				echo.-------------------------------------------------------------------------------
				echo.####正在生成 Microsoft .NET Framework 3.5 集成日志文件#########################
				echo.-------------------------------------------------------------------------------
				echo.
				echo.正在写入 Microsoft .NET Framework 3.5 集成日志文件……
				call :GetFeatures "%InstallMount%", "NetFX35.txt"
				echo.          
			)
			echo.-------------------------------------------------------------------------------
			echo.####集成 Microsoft .NET Framework 3.5 已完成###################################
			echo.-------------------------------------------------------------------------------
			echo.
		) else (
			echo.Microsoft .NET Framework 3.5 已被启用……
			echo.
			echo.-------------------------------------------------------------------------------
			echo.####集成 Microsoft .NET Framework 3.5 已停止###################################
			echo.-------------------------------------------------------------------------------
			echo.
			goto :Stop
		)
	)
)
call :RemoveFile "%Temp%\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
:Stop
echo.===============================================================================
echo.
pause

set NetFX35=
set PackageArchitecture=
set PackageServicePackBuild=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成适用于 Windows 10 v1507 和 v1511 源操作系统的 Microsoft .NET Framework 4.6.2 模块
::-------------------------------------------------------------------------------------------
:IntNetFX462

setlocal

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 集成 Microsoft .NET Framework 4.6.2
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置映像软件包体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"

:: 检查 Microsoft .NET Framework 4.6.2 包文件是否存在
if not exist "%NetFX462%\Microsoft-Windows-NetFX462-Package~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.Microsoft .NET Framework 4.6.2 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-NetFX462-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\NetFX462^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft .NET Framework 4.6.2 包文件是否存在
if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "Core" if "%ImageEdition%" neq "CoreN" if "%ImageEdition%" neq "CoreSingleLanguage" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
	if not exist "%NetFX462%\Windows10.0-KB4051600-%ImageArchitecture%.cab" (
		echo.Microsoft .NET Framework 4.6.2 包文件夹缺少以下文件……
		echo.
		echo."Windows10.0-KB4051600-%ImageArchitecture%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\NetFX462^> 文件夹……
		goto :Stop
	)
)

:: 检查 Microsoft .NET Framework 4.6.2 包文件是否存在
if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Core" if "%ImageEdition%" neq "CoreN" if "%ImageEdition%" neq "CoreSingleLanguage" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" (
	if not exist "%NetFX462%\Windows10.0-KB4054057-%ImageArchitecture%.cab" (
		echo.Microsoft .NET Framework 4.6.2 包文件夹缺少以下文件……
		echo.
		echo."Windows10.0-KB4054057-%ImageArchitecture%.cab""
		echo.
		echo.请复制上述文件到 ^<Packs\NetFX462^> 文件夹……
		goto :Stop
	)
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft .NET Framework 4.6.2################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft .NET Framework 4.6.2####################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (		
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		echo.
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft .NET Framework 4.6.2 基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%NetFX462%\Microsoft-Windows-NetFX462-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
		if exist "%NetFX462%\Microsoft-Windows-NetFX462-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.6.2 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%NetFX462%\Microsoft-Windows-NetFX462-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%.cab"
		)
		if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "Core" if "%ImageEdition%" neq "CoreN" if "%ImageEdition%" neq "CoreSingleLanguage" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.6.2 更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%NetFX462%\Windows10.0-KB4051600-%ImageArchitecture%.cab"
		)
		if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Core" if "%ImageEdition%" neq "CoreN" if "%ImageEdition%" neq "CoreSingleLanguage" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.6.2 更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%NetFX462%\Windows10.0-KB4054057-%ImageArchitecture%.cab"
		)
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 4.6.2 基础包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%NetFX462%\Microsoft-Windows-NetFX462-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	if exist "%NetFX462%\Microsoft-Windows-NetFX462-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft .NET Framework 4.6.2 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%NetFX462%\Microsoft-Windows-NetFX462-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%.cab"
	)
	if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "Core" if "%ImageEdition%" neq "CoreN" if "%ImageEdition%" neq "CoreSingleLanguage" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft .NET Framework 4.6.2 更新包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%NetFX462%\Windows10.0-KB4051600-%ImageArchitecture%.cab"
	)
	if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Core" if "%ImageEdition%" neq "CoreN" if "%ImageEdition%" neq "CoreSingleLanguage" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft .NET Framework 4.6.2 更新包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%NetFX462%\Windows10.0-KB4054057-%ImageArchitecture%.cab"
	)
)
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft .NET Framework 4.6.2 已完成#################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set NetFX462=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft .NET Framework 4.8 模块
::-------------------------------------------------------------------------------------------
:IntNetFX48

setlocal

set NetFX48Pkg=
set NetFX48LpPkg=

cls
echo.===============================================================================
echo.               MSMG 工具箱 - 集成 Microsoft .NET Framework 4.8
echo.===============================================================================
echo.

:: 设置 Microsoft .NET Framework 4.8 包文件夹路径
set "NetFX48=%NetFX48%\%SelectedSourceOS%"

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置映像软件包体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm" set "PackageArchitecture=arm"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 设置映像包服务包内部版本等级
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageBuild%" equ "14393" set "NetFX48Pkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.cab"
	if "%ImageBuild%" equ "14393" set "NetFX48LpPkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~10.0.14393.0.cab"	
	if "%ImageBuild%" equ "15063" set "NetFX48Pkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.cab"
	if "%ImageBuild%" equ "15063" set "NetFX48LpPkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~10.0.14393.0.cab"	
	if "%ImageBuild%" equ "16299" set "NetFX48Pkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.cab"
	if "%ImageBuild%" equ "16299" set "NetFX48LpPkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~10.0.16299.15.cab"	
	if "%ImageBuild%" equ "17134" set "NetFX48Pkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.cab"
	if "%ImageBuild%" equ "17134" set "NetFX48LpPkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~10.0.16299.15.cab"	
	if "%ImageBuild%" equ "17763" set "NetFX48Pkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.cab"
	if "%ImageBuild%" equ "17763" set "NetFX48LpPkg=Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~10.0.16299.15.cab"
)

:: 检查 Microsoft .NET Framework 4.8 包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%NetFX48%\Windows6.1-KB4019990-%ImageArchitecture%.cab" (
	echo.Microsoft .NET Framework 4.8 包文件夹缺少以下文件……
	echo.
	echo."Windows6.1-KB4019990-%ImageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\NetFX48\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft .NET Framework 4.8 包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%NetFX48%\NetFX48.tpk" (
	echo.Microsoft .NET Framework 4.8 包文件夹缺少以下文件……
	echo.
	echo."NetFX48.tpk"
	echo.
	echo.请复制上述文件到 ^<Packs\NetFX48\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft .NET Framework 4.8 包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%NetFX48%\NetFX48_%ImageArchitecture%.reg" (
	echo.Microsoft .NET Framework 4.8 包文件夹缺少以下文件……
	echo.
	echo."NetFX48_%ImageArchitecture%.reg"
	echo.
	echo.请复制上述文件到 ^<Packs\NetFX48\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft .NET Framework 4.8 包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%NetFX48%\Microsoft-Windows-NetFx48-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab" (
	echo.Microsoft .NET Framework 4.8 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-NetFx48-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\NetFX48\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft .NET Framework 4.8 包文件是否存在
if "%SelectedSourceOS%" equ "w10" if not exist "%NetFX48%\%NetFX48Pkg%" (
	echo.Microsoft .NET Framework 4.8 包文件夹缺少以下文件……
	echo.
	echo."%NetFX48Pkg%"
	echo.
	echo.请复制上述文件到 ^<Packs\NetFX48\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft .NET Framework 4.8##################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft .NET Framework 4.8######################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (		
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		if "%SelectedSourceOS%" equ "w7" (
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.8 先决条件更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%NetFX48%\Windows6.1-KB4019990-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.8 基础包……
			echo.-------------------------------------------------------------------------------
			if "%ImageArchitecture%" equ "x86" call :ApplyImage "%NetFX48%\NetFX48.tpk", 1, "%InstallMount%\%%i"
			if "%ImageArchitecture%" equ "x64" call :ApplyImage "%NetFX48%\NetFX48.tpk", 2, "%InstallMount%\%%i"
			
			if exist "%NetFX48%\NetFX48_%ImageDefaultLanguage%.tpk" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft .NET Framework 4.8 [%ImageDefaultLanguage%] 语言包……
				echo.-------------------------------------------------------------------------------
				if "%ImageArchitecture%" equ "x86" call :ApplyImage "%NetFX48%\NetFX48_%ImageDefaultLanguage%.tpk", 1, "%InstallMount%\%%i"
				if "%ImageArchitecture%" equ "x64" call :ApplyImage "%NetFX48%\NetFX48_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%\%%i"
			)

			echo.-------------------------------------------------------------------------------
			echo.####正在合并 Microsoft .NET Framework 4.8 注册表设置###########################
			echo.-------------------------------------------------------------------------------
			echo.
			echo.正在安装映像注册表……
			call :MountImageRegistry "%InstallMount%\%%i"
			echo.正在将注册表设置合并到映像注册表……
			call :ImportRegistry2Image "%NetFX48%\NetFX48_%ImageArchitecture%.reg"

			if exist "%NetFX48%\NetFX48_%ImageArchitecture%_%ImageDefaultLanguage%.reg" (
				call :ImportRegistry2Image "%NetFX48%\NetFX48_%ImageArchitecture%_%ImageDefaultLanguage%.reg"
			)

			echo.正在卸载映像注册表……
			call :UnMountImageRegistry
			echo.
		)
		
		if "%SelectedSourceOS%" equ "w81" (
			if not exist "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~6.3.9600.16384.cab" (
				call :AddPackage "%InstallMount%\%%i", "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab"
			)

			if exist "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~6.3.9600.16384.cab" (
				echo.
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft .NET Framework 4.8 基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft .NET Framework 4.8 [%ImageDefaultLanguage%] 语言包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~6.3.9600.16384.cab"
			)		
		)

		if "%SelectedSourceOS%" equ "w10" (
			if not exist "%NetFX48%\%NetFX48LpPkg%" (
				call :AddPackage "%InstallMount%\%%i", "%NetFX48%\%NetFX48Pkg%"
			)

			if exist "%NetFX48%\%NetFX48LpPkg%" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft .NET Framework 4.8 基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%NetFX48%\%NetFX48Pkg%"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft .NET Framework 4.8 [%ImageDefaultLanguage%] 语言包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%NetFX48%\%NetFX48LpPkg%"
			)		
		)
	)
) else (
	if "%SelectedSourceOS%" equ "w7" (
		echo.
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft .NET Framework 4.8 先决条件更新包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%NetFX48%\Windows6.1-KB4019990-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft .NET Framework 4.8 基础包……
		echo.-------------------------------------------------------------------------------
		if "%ImageArchitecture%" equ "x86" call :ApplyImage "%NetFX48%\NetFX48.tpk", 1, "%InstallMount%"
		if "%ImageArchitecture%" equ "x64" call :ApplyImage "%NetFX48%\NetFX48.tpk", 2, "%InstallMount%"

		if exist "%NetFX48%\NetFX48_%ImageDefaultLanguage%.tpk" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.8 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			if "%ImageArchitecture%" equ "x86" call :ApplyImage "%NetFX48%\NetFX48_%ImageDefaultLanguage%.tpk", 1, "%InstallMount%"
			if "%ImageArchitecture%" equ "x64" call :ApplyImage "%NetFX48%\NetFX48_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%"
		)

		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Microsoft .NET Framework 4.8 注册表设置###########################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%"
		echo.正在将注册表设置合并到映像注册表……
		call :ImportRegistry2Image "%NetFX48%\NetFX48_%ImageArchitecture%.reg"

		if exist "%NetFX48%\NetFX48_%ImageArchitecture%_%ImageDefaultLanguage%.reg" (
			call :ImportRegistry2Image "%NetFX48%\NetFX48_%ImageArchitecture%_%ImageDefaultLanguage%.reg"
		)

		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
		echo.
	)
		
	if "%SelectedSourceOS%" equ "w81" (
		if not exist "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~6.3.9600.16384.cab" (
			call :AddPackage "%InstallMount%", "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab"
		)

		if exist "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~6.3.9600.16384.cab" (
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.8 基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.8 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%NetFX48%\Microsoft-Windows-NetFX48-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~6.3.9600.16384.cab"
		)		
	)

	if "%SelectedSourceOS%" equ "w10" (
		if not exist "%NetFX48%\%NetFX48LpPkg%" (
			call :AddPackage "%InstallMount%", "%NetFX48%\%NetFX48Pkg%"
		)

		if exist "%NetFX48%\%NetFX48LpPkg%" (
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.8 基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%NetFX48%\%NetFX48Pkg%"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft .NET Framework 4.8 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%NetFX48%\%NetFX48LpPkg%"
		)		
	)
)
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft .NET Framework 4.8 已完成###################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set NetFX48=
set NetFX48Pkg=
set NetFX48LpPkg=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft Internet Explorer 11 模块
::-------------------------------------------------------------------------------------------
:IntIE11

setlocal

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 集成 Microsoft Internet Explorer 11
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置映像软件包体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"

:: 检查 Microsoft Internet Explorer 11 包文件是否存在
if not exist "%IE11%\Microsoft-Windows-PlatformUpdate-Win7-SRV08R2-Package~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.Microsoft Internet Explorer 11 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-PlatformUpdate-Win7-SRV08R2-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\IE11^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft Internet Explorer 11 包文件是否存在
if not exist "%IE11%\Microsoft-Windows-InternetExplorer-Package~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.Microsoft Internet Explorer 11 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-InternetExplorer-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\IE11^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft Internet Explorer 11 包文件是否存在
if "%ImageDefaultLanguage%" equ "en-US" if not exist "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~en-US.cab" (
	echo.Microsoft Internet Explorer 11 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~en-US.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\IE11^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft Internet Explorer 11 包文件是否存在
if "%ImageDefaultLanguage%" equ "en-US" if not exist "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~en-US.cab" (
	echo.Microsoft Internet Explorer 11 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~en-US.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\IE11^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft Internet Explorer 11 包文件是否存在
if "%ImageDefaultLanguage%" neq "en-US" if not exist "%IE11%\Microsoft-Windows-InternetExplorer-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%.cab" (
	echo.Microsoft Internet Explorer 11 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-InternetExplorer-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\IE11^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft Internet Explorer 11################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft Internet Explorer 11####################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
			
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Internet Explorer 11 先决条件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-PlatformUpdate-Win7-SRV08R2-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Internet Explorer 11 基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-InternetExplorer-Package~31bf3856ad364e35~%PackageArchitecture%.cab"

		if "%ImageDefaultLanguage%" equ "en-US" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Internet Explorer 11 连字符包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~en-US.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Internet Explorer 11 拼写包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~en-US.cab"
		)
		if "%ImageDefaultLanguage%" neq "en-US" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Internet Explorer 11 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-InternetExplorer-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%.cab"
			
			if exist "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~%ImageDefaultLanguage%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft Internet Explorer 11 连字符包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~%ImageDefaultLanguage%.cab"
			) else (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft Internet Explorer 11 连字符包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~en-US.cab"
			)
			if exist "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~%ImageDefaultLanguage%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft Internet Explorer 11 拼写包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~%ImageDefaultLanguage%.cab"
			) else (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft Internet Explorer 11 拼写包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~en-US.cab"
			)			
		)
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Internet Explorer 11 先决条件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-PlatformUpdate-Win7-SRV08R2-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Internet Explorer 11 基础包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-InternetExplorer-Package~31bf3856ad364e35~%PackageArchitecture%.cab"

	if "%ImageDefaultLanguage%" equ "en-US" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Internet Explorer 11 连字符包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~en-US.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Internet Explorer 11 拼写包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~en-US.cab"
	)
	if "%ImageDefaultLanguage%" neq "en-US" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Internet Explorer 11 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-InternetExplorer-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%.cab"
			
		if exist "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~%ImageDefaultLanguage%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Internet Explorer 11 连字符包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~%ImageDefaultLanguage%.cab"
		) else (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Internet Explorer 11 连字符包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-IE-Hyphenation-Package~31bf3856ad364e35~en-US.cab"
		)
		if exist "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~%ImageDefaultLanguage%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Internet Explorer 11 拼写包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~%ImageDefaultLanguage%.cab"
		) else (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Internet Explorer 11 拼写包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%IE11%\Microsoft-Windows-IE-Spelling-Package~31bf3856ad364e35~en-US.cab"
		)			
	)
)	
echo.-------------------------------------------------------------------------------
echo.####集成 Internet Explorer 11 已完成###########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set IE11=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成远程桌面协议（RDP）8.0 和 8.1 模块
::-------------------------------------------------------------------------------------------
:IntRDP81

setlocal

cls
echo.===============================================================================
echo.               MSMG 工具箱 - 集成远程桌面协议 ^(RDP^) 8.0 和 8.1
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置映像软件包体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"

:: 检查远程桌面协议（RDP）8.0 和 8.1 包文件是否存在
if not exist "%RDP81%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.远程桌面协议 ^(RDP^) 8.0 和 8.1 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RDP81^> 文件夹……
	goto :Stop
)

:: 检查远程桌面协议（RDP）8.0 和 8.1 包文件是否存在
if not exist "%RDP81%\Microsoft-Windows-RDP-WinIP-Package~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.远程桌面协议 ^(RDP^) 8.0 和 8.1 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-RDP-WinIP-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RDP81^> 文件夹……
	goto :Stop
)

:: 检查远程桌面协议（RDP）8.0 和 8.1 包文件是否存在
if not exist "%RDP81%\Microsoft-Windows-RDP-BlueIP-Package~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.远程桌面协议 ^(RDP^) 8.0 和 8.1 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-RDP-BlueIP-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RDP81^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成远程桌面协议 ^(RDP^) 8.0 和 8.1##################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成远程桌面协议 ^(RDP^) 8.0 和 8.1######################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
			
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		echo.-------------------------------------------------------------------------------
		echo.正在集成远程桌面协议 ^(RDP^) 8.0 和 8.1 先决条件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%RDP81%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成远程桌面协议 ^(RDP^) 8.0 和 8.1 先决条件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%RDP81%\Microsoft-Windows-RDP-WinIP-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成远程桌面协议 ^(RDP^) 8.0 和 8.1 软件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%RDP81%\Microsoft-Windows-RDP-BlueIP-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成远程桌面协议 ^(RDP^) 8.0 和 8.1 先决条件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%RDP81%\Microsoft-Windows-WinPE-LanguagePack-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成远程桌面协议 ^(RDP^) 8.0 和 8.1 先决条件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%RDP81%\Microsoft-Windows-RDP-WinIP-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成远程桌面协议 ^(RDP^) 8.0 和 8.1 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%RDP81%\Microsoft-Windows-RDP-BlueIP-Package~31bf3856ad364e35~%PackageArchitecture%.cab"
)	
echo.-------------------------------------------------------------------------------
echo.####集成远程桌面协议 ^(RDP^) 8.0 和 8.1 已完成###################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set RDP81=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows Management Framework（WMF）5.1 模块
::-------------------------------------------------------------------------------------------
:IntWMF

setlocal

cls
echo.===============================================================================
echo.           MSMG 工具箱 - 集成 Windows Management Framework ^(WMF^) 5.1
echo.===============================================================================
echo.

:: 根据所选源操作系统设置 Windows Management Framework（WMF）5.1 包文件夹路径
set "WMF=%WMF%\%SelectedSourceOS%"

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 检查 Windows Management Framework（WMF）5.1 包文件是否存在
if "%SelectedSourceOS%" equ "w7" if "%ImageArchitecture%" equ "x64" if not exist "%WMF%\Windows6.1-KB2809215-%ImageArchitecture%.cab" (
	echo.Windows Management Framework 5 包文件夹缺少以下文件……
	echo.
	echo."Windows6.1-KB2809215-%ImageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WMF\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows Management Framework（WMF）5.1 包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%WMF%\Windows6.1-KB2872035-%ImageArchitecture%.cab" (
	echo.Windows Management Framework 5 包文件夹缺少以下文件……
	echo.
	echo."Windows6.1-KB2872035-%ImageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WMF\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows Management Framework（WMF）5.1 包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%WMF%\Windows6.1-KB3033929-%ImageArchitecture%.cab" (
	echo.Windows Management Framework 5 包文件夹缺少以下文件……
	echo.
	echo."Windows6.1-KB3033929-%ImageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WMF\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows Management Framework（WMF）5.1 包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%WMF%\Windows6.1-KB3191566-%ImageArchitecture%.cab" (
	echo.Windows Management Framework 5 包文件夹缺少以下文件……
	echo.
	echo."Windows6.1-KB3191566-%ImageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WMF\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows Management Framework（WMF）5.1 包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%WMF%\Windows8.1-KB3191564-%ImageArchitecture%.cab" (
	echo.Windows Management Framework 5 包文件夹缺少以下文件……
	echo.
	echo."Windows8.1-KB3191564-%ImageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WMF\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows Management Framework ^(WMF^) 5.1########################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows Management Framework ^(WMF^) 5.1############################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		 
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul
				
		if "%SelectedSourceOS%" equ "w7" (
			echo.
			if "%ImageArchitecture%" equ "x64" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows Management Framework ^(WMF^) 5.1 先决条件包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%WMF%\Windows6.1-KB2809215-%ImageArchitecture%.cab"
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows Management Framework ^(WMF^) 5.1 先决条件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%WMF%\Windows6.1-KB2872035-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows Management Framework ^(WMF^) 5.1 先决条件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%WMF%\Windows6.1-KB3033929-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows Management Framework ^(WMF^) 5.1 功能包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%WMF%\Windows6.1-KB3191566-%ImageArchitecture%.cab"
		)		
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%InstallMount%\%%i", "%WMF%\Windows8.1-KB3191564-%ImageArchitecture%.cab"
	)
) else (	
	if "%SelectedSourceOS%" equ "w7" (
		echo.
		if "%ImageArchitecture%" equ "x64" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows Management Framework ^(WMF^) 5.1 先决条件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%WMF%\Windows6.1-KB2809215-%ImageArchitecture%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows Management Framework ^(WMF^) 5.1 先决条件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%WMF%\Windows6.1-KB2872035-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows Management Framework ^(WMF^) 5.1 先决条件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%WMF%\Windows6.1-KB3033929-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows Management Framework ^(WMF^) 5.1 功能包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%WMF%\Windows6.1-KB3191566-%ImageArchitecture%.cab"
	)
	if "%SelectedSourceOS%" equ "w81" call :AddPackage "%InstallMount%", "%WMF%\Windows8.1-KB3191564-%ImageArchitecture%.cab"
)	
echo.-------------------------------------------------------------------------------
echo.####集成 Windows Management Framework ^(WMF^) 5.1 已完成#########################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set WMF=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft Win32 计算器模块
::-------------------------------------------------------------------------------------------
:IntWin32Calc

setlocal

set PackageArchitecture=

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 集成 Microsoft Win32 计算器
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包索引
if "%ImageArchitecture%" equ "x86" set "PackageIndex=1"
if "%ImageArchitecture%" equ "x64" set "PackageIndex=2"
if "%ImageArchitecture%" equ "arm64" set "PackageIndex=3"

:: 检查 Microsoft Win32 计算器包文件是否存在
if not exist "%Win32Calc%\Win32Calc.tpk" (
	echo.Microsoft Win32 计算器包文件夹缺少以下文件……
	echo.
	echo."Win32Calc.tpk"
	echo.
	echo.请复制上述文件到 ^<Packs\Win32Calc^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft Win32 计算器包文件是否存在
if not exist "%Win32Calc%\Win32Calc_%ImageDefaultLanguage%.tpk" (
	echo.Microsoft Win32 计算器包文件夹缺少以下文件……
	echo.
	echo."Win32Calc_%ImageDefaultLanguage%.tpk"
	echo.
	echo.请复制上述文件到 ^<Packs\Win32Calc^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft Win32 计算器包文件是否存在
if not exist "%Win32Calc%\Win32Calc_%ImageArchitecture%.reg" (
	echo.Microsoft Win32 计算器包文件夹缺少以下文件……
	echo.
	echo."Win32Calc_%ImageArchitecture%.reg"
	echo.
	echo.请复制上述文件到 ^<Packs\Win32Calc^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft Win32 计算器########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft Win32 计算器############################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
			
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Win32 计算器基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Win32Calc%\Win32Calc.tpk", %PackageIndex%, "%InstallMount%\%%i"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Win32 计算器 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Win32Calc%\Win32Calc_%ImageDefaultLanguage%.tpk", %PackageIndex%, "%InstallMount%\%%i"
		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Microsoft Win32 计算器注册表设置##################################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"
		echo.正在将注册表设置合并到映像注册表……
		call :ImportRegistry2Image "%Win32Calc%\Win32Calc_%ImageArchitecture%.reg"
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Win32 计算器基础包……
	echo.-------------------------------------------------------------------------------
	call :ApplyImage "%Win32Calc%\Win32Calc.tpk", %PackageIndex%, "%InstallMount%"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Win32 计算器 [%ImageDefaultLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	call :ApplyImage "%Win32Calc%\Win32Calc_%ImageDefaultLanguage%.tpk", %PackageIndex%, "%InstallMount%"
	echo.-------------------------------------------------------------------------------
	echo.####正在合并 Microsoft Win32 计算器注册表设置##################################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"
	echo.正在将注册表设置合并到映像注册表……
	call :ImportRegistry2Image "%Win32Calc%\Win32Calc_%ImageArchitecture%.reg"
	echo.正在卸载映像注册表……
	call :UnMountImageRegistry
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft Win32 计算器已完成##########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Win32Calc=
set PackageIndex=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 重复数据删除模块
::-------------------------------------------------------------------------------------------
:IntDedup

setlocal

cls
echo.===============================================================================
echo.                   MSMG 工具箱 - 集成 Windows 重复数据删除
echo.===============================================================================
echo.

set "FSSMRESReg=%Dedup%\fssmres.dll.reg"

:: 根据所选源操作系统设置 Windows 重复数据删除包文件夹路径
if "%SelectedSourceOS%"=="w81" set "Dedup=%Dedup%\%SelectedSourceOS%"
if "%SelectedSourceOS%"=="w10" set "Dedup=%Dedup%\%SelectedSourceOS%\10.0.%ImageBuild%"

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包服务包内部版本
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageBuild%" equ "10586" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
	if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~6.3.9600.16384.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~6.3.9600.16384.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~6.3.9600.16384.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~6.3.9600.16384.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10586" if not exist "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10586" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10586" if "%ImageDefaultLanguage%" neq "de-DE" if "%ImageDefaultLanguage%" neq "es-ES" if "%ImageDefaultLanguage%" neq "fr-FR" if "%ImageDefaultLanguage%" neq "it-IT" if "%ImageDefaultLanguage%" neq "ja-JP" if "%ImageDefaultLanguage%" neq "ko-KR" if "%ImageDefaultLanguage%" neq "pt-BR" if "%ImageDefaultLanguage%" neq "ru-RU" if "%ImageDefaultLanguage%" neq "tr-TR" if "%ImageDefaultLanguage%" neq "zh-CN" if "%ImageDefaultLanguage%" neq "zh-TW" (
	if not exist "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 重复数据删除包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
		goto :Stop
	)
	
	if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab" (
		echo.Windows 重复数据删除包文件夹缺少以下文件……
		echo.
		echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.
		echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
		goto :Stop
	)
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10586" (
	for %%j in (de-DE, es-ES, fr-FR, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, tr-TR, zh-CN, zh-TW) do (
		if "%ImageDefaultLanguage%" equ "%%j" (
			if not exist "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.Windows 重复数据删除包文件夹缺少以下文件……
				echo.
				echo."Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.
				echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
				goto :Stop
			)
			
			if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
				echo.Windows 重复数据删除包文件夹缺少以下文件……
				echo.
				echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.
				echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
				goto :Stop
			)			
		)
	)
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if not exist "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if not exist "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "15063" if not exist "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "15063" if not exist "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "15063" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "15063" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "16299" if not exist "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "16299" if not exist "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "16299" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 重复数据删除包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "16299" if not exist "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 重复数据删除包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Dedup\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 重复数据删除##########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 重复数据删除##############################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
			
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		if "%SelectedSourceOS%" equ "w81" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~6.3.9600.16384.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~6.3.9600.16384.cab"
		)

		if "%SelectedSourceOS%" equ "w10" (
			if "%ImageBuild%" equ "10586" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 文件服务器基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				if "%ImageDefaultLanguage%" neq "de-DE" if "%ImageDefaultLanguage%" neq "es-ES" if "%ImageDefaultLanguage%" neq "fr-FR" if "%ImageDefaultLanguage%" neq "it-IT" if "%ImageDefaultLanguage%" neq "ja-JP" if "%ImageDefaultLanguage%" neq "ko-KR" if "%ImageDefaultLanguage%" neq "pt-BR" if "%ImageDefaultLanguage%" neq "ru-RU" if "%ImageDefaultLanguage%" neq "tr-TR" if "%ImageDefaultLanguage%" neq "zh-CN" if "%ImageDefaultLanguage%" neq "zh-TW" (
					echo.正在集成 Windows 文件服务器 [en-US] 语言包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
				)
				for %%j in (de-DE, es-ES, fr-FR, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, tr-TR, zh-CN, zh-TW) do (
					if "%ImageDefaultLanguage%" equ "%%j" (
						echo.正在集成 Windows 文件服务器 [%ImageDefaultLanguage%] 语言包……
						echo.-------------------------------------------------------------------------------
						call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
					)
				)
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 重复数据删除基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				if "%ImageDefaultLanguage%" neq "de-DE" if "%ImageDefaultLanguage%" neq "es-ES" if "%ImageDefaultLanguage%" neq "fr-FR" if "%ImageDefaultLanguage%" neq "it-IT" if "%ImageDefaultLanguage%" neq "ja-JP" if "%ImageDefaultLanguage%" neq "ko-KR" if "%ImageDefaultLanguage%" neq "pt-BR" if "%ImageDefaultLanguage%" neq "ru-RU" if "%ImageDefaultLanguage%" neq "tr-TR" if "%ImageDefaultLanguage%" neq "zh-CN" if "%ImageDefaultLanguage%" neq "zh-TW" (
					echo.正在集成 Windows 重复数据删除 [en-US] 语言包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
				)
				for %%j in (de-DE, es-ES, fr-FR, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, tr-TR, zh-CN, zh-TW) do (
					if "%ImageDefaultLanguage%" equ "%%j" (
						echo.正在集成 Windows 重复数据删除 [%ImageDefaultLanguage%] 语言包……
						echo.-------------------------------------------------------------------------------
						call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
					)
				)
			)
			
			if "%ImageBuild%" equ "14393" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 文件服务器核心基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 文件服务器核心 [%ImageDefaultLanguage%] 语言包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 重复数据删除基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 重复数据删除 [%ImageDefaultLanguage%] 语言包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
				if exist "%Dedup%\Updates\*.cab" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 重复数据删除更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Dedup%\Updates"
				)
			)
			
			if "%ImageBuild%" equ "15063" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 文件服务器核心基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 文件服务器核心 [en-US] 软件包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 重复数据删除基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 重复数据删除 [en-US] 软件包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
			)

			if "%ImageBuild%" geq "16299" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 文件服务器核心基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 文件服务器核心 [en-US] 软件包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 重复数据删除基础包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 重复数据删除 [en-US] 软件包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
			)
		)
	)
) else (
	if "%SelectedSourceOS%" equ "w81" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 文件服务器基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 文件服务器 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~6.3.9600.16384.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 重复数据删除基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 重复数据删除 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~6.3.9600.16384.cab"
	)

	if "%SelectedSourceOS%" equ "w10" (
		if "%ImageBuild%" equ "10586" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			if "%ImageDefaultLanguage%" neq "de-DE" if "%ImageDefaultLanguage%" neq "es-ES" if "%ImageDefaultLanguage%" neq "fr-FR" if "%ImageDefaultLanguage%" neq "it-IT" if "%ImageDefaultLanguage%" neq "ja-JP" if "%ImageDefaultLanguage%" neq "ko-KR" if "%ImageDefaultLanguage%" neq "pt-BR" if "%ImageDefaultLanguage%" neq "ru-RU" if "%ImageDefaultLanguage%" neq "tr-TR" if "%ImageDefaultLanguage%" neq "zh-CN" if "%ImageDefaultLanguage%" neq "zh-TW" (
				echo.正在集成 Windows 文件服务器 [en-US] 语言包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
			)
			for %%j in (de-DE, es-ES, fr-FR, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, tr-TR, zh-CN, zh-TW) do (
				if "%ImageDefaultLanguage%" equ "%%j" (
					echo.正在集成 Windows 文件服务器 [%ImageDefaultLanguage%] 语言包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
				)
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			if "%ImageDefaultLanguage%" neq "de-DE" if "%ImageDefaultLanguage%" neq "es-ES" if "%ImageDefaultLanguage%" neq "fr-FR" if "%ImageDefaultLanguage%" neq "it-IT" if "%ImageDefaultLanguage%" neq "ja-JP" if "%ImageDefaultLanguage%" neq "ko-KR" if "%ImageDefaultLanguage%" neq "pt-BR" if "%ImageDefaultLanguage%" neq "ru-RU" if "%ImageDefaultLanguage%" neq "tr-TR" if "%ImageDefaultLanguage%" neq "zh-CN" if "%ImageDefaultLanguage%" neq "zh-TW" (
				echo.正在集成 Windows 重复数据删除 [en-US] 语言包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
			)
			for %%j in (de-DE, es-ES, fr-FR, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, tr-TR, zh-CN, zh-TW) do (
				if "%ImageDefaultLanguage%" equ "%%j" (
					echo.正在集成 Windows 重复数据删除 [%ImageDefaultLanguage%] 语言包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
				)
			)
		)
		
		if "%ImageBuild%" equ "14393" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器核心基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器核心 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
			if exist "%Dedup%\Updates\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 重复数据删除更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Dedup%\Updates"
			)
		)
		
		if "%ImageBuild%" equ "15063" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器核心基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器核心 [en-US] 软件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除 [en-US] 软件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~en-US~%ImageVersion%.%PackageServicePackBuild%.cab"
		)

		if "%ImageBuild%" geq "16299" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器核心基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 文件服务器核心 [en-US] 软件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-FileServer-ServerCore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 重复数据删除 [en-US] 软件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Dedup%\Microsoft-Windows-Dedup-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
	)			
)
echo.-------------------------------------------------------------------------------
echo.####正在启用 Windows 重复数据删除功能##########################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

		if "%SelectedSourceOS%" equ "w81" (
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在启用 Windows 重复数据删除功能……
			echo.-------------------------------------------------------------------------------
			call :EnableFeature "%InstallMount%\%%i", "Dedup-Core /All"
			echo.-------------------------------------------------------------------------------
			echo.正在启用 Windows 文件服务搜索服务功能……
			echo.-------------------------------------------------------------------------------
			call :EnableFeature "%InstallMount%\%%i", "File-Services-Search-Service /All"
		)

		if "%SelectedSourceOS%" equ "w10" call :EnableFeature "%InstallMount%\%%i", "Dedup-Core /All"
	)
) else (
	if "%SelectedSourceOS%" equ "w81" (
		echo.
		echo.-------------------------------------------------------------------------------
		echo.正在启用 Windows 重复数据删除功能……
		echo.-------------------------------------------------------------------------------
		call :EnableFeature "%InstallMount%", "Dedup-Core /All"
		echo.-------------------------------------------------------------------------------
		echo.正在启用 Windows 文件服务搜索服务功能……
		echo.-------------------------------------------------------------------------------
		call :EnableFeature "%InstallMount%", "File-Services-Search-Service /All"
	)

	if "%SelectedSourceOS%" equ "w10" call :EnableFeature "%InstallMount%", "Dedup-Core /All"
)
echo.-------------------------------------------------------------------------------
echo.####正在合并 Windows 文件服务器 ^(fssmres.dll^) 修复注册表设置###################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"
		echo.正在将注册表设置合并到映像注册表……
		call :ImportRegistry2Image "%FSSMRESReg%"
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
	)
) else (
	echo.
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"
	echo.正在将注册表设置合并到映像注册表……
	call :ImportRegistry2Image "%FSSMRESReg%"
	echo.正在卸载映像注册表……
	call :UnMountImageRegistry
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 重复数据删除已完成############################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Dedup=
set PackageServicePackBuild=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows To Go 工作区模块
::-------------------------------------------------------------------------------------------
:IntWinToGo

setlocal

cls
echo.===============================================================================
echo.                   MSMG 工具箱 - 集成 Windows To Go 工作区
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置 Windows To Go 工作区包路径
if "%SelectedSourceOS%" equ "w81" set "WinToGo=%WinToGo%\%SelectedSourceOS%"
if "%SelectedSourceOS%" equ "w10" set "WinToGo=%WinToGo%\%SelectedSourceOS%\10.0.%ImageBuild%"

:: 设置软件包服务包内部版本
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageBuild%" equ "10240" set "PackageServicePackBuild=16384"
	if "%ImageBuild%" equ "10586" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
	if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
)

:: 设置软件包索引和体系结构
if "%ImageArchitecture%" equ "x86" (
	set "PackageIndex=1"
	set "PackageArchitecture=x86"
)

if "%ImageArchitecture%" equ "x64" (
	set "PackageIndex=2"
	set "PackageArchitecture=amd64"
)

:: 检查 Windows To Go 工作区包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%WinToGo%\WTG.tpk" (
	echo.Windows To Go 工作区包文件“WTG.tpk”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\WinToGo\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows To Go 工作区包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%WinToGo%\WTG_%ImageDefaultLanguage%.tpk" (
	echo.Windows To Go 工作区包文件“WTG_%ImageDefaultLanguage%.tpk”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\WinToGo\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows To Go 工作区包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%WinToGo%\WTG_%ImageArchitecture%.reg" (
	echo.Windows To Go 工作区包文件“WTG_%ImageArchitecture%.reg”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\WinToGo\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows To Go 工作区包文件是否存在
if "%SelectedSourceOS%" equ "w10" if not exist "%WinToGo%\Microsoft-Windows-PortableWorkspaces-Creator-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows To Go 工作区包文件夹缺少以下文件……
	echo.
	echo.Microsoft-Windows-PortableWorkspaces-Creator-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WinToGo\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows To Go 工作区包文件是否存在
if "%SelectedSourceOS%" equ "w10" if not exist "%WinToGo%\Microsoft-Windows-PortableWorkspaces-Creator-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows To Go 工作区包文件夹缺少以下文件……
	echo.
	echo.Microsoft-Windows-PortableWorkspaces-Creator-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WinToGo\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows To Go 工作区##########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows To Go 工作区##############################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul
		echo.

		if "%SelectedSourceOS%" equ "w81" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows To Go 工作区基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%WinToGo%\WTG.tpk", %PackageIndex%, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows To Go 工作区 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%WinToGo%\WTG_%ImageDefaultLanguage%.tpk", %PackageIndex%, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.####正在合并 Windows To Go 工作区注册表设置####################################
			echo.-------------------------------------------------------------------------------
			echo.
			echo.正在安装映像注册表……
			call :MountImageRegistry "%InstallMount%\%%i"
			echo.正在将注册表设置合并到映像注册表……
			call :ImportRegistry2Image "%WinToGo%\WTG_%ImageArchitecture%.reg"
			echo.正在卸载映像注册表……
			call :UnMountImageRegistry		  
		)

		if "%SelectedSourceOS%" equ "w10" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows To Go 工作区基础包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", %WinToGo%\Microsoft-Windows-PortableWorkspaces-Creator-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows To Go 工作区 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", %WinToGo%\Microsoft-Windows-PortableWorkspaces-Creator-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab
		)
	)
) else (
	if "%SelectedSourceOS%" equ "w81" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows To Go 工作区基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%WinToGo%\WTG.tpk", %PackageIndex%, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows To Go 工作区 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%WinToGo%\WTG_%ImageDefaultLanguage%.tpk", %PackageIndex%, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Windows To Go 工作区注册表设置####################################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%"
		echo.正在将注册表设置合并到映像注册表……
		call :ImportRegistry2Image "%WinToGo%\WTG_%ImageArchitecture%.reg"
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
		echo.			  
	)

	if "%SelectedSourceOS%" equ "w10" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows To Go 工作区基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", %WinToGo%\Microsoft-Windows-PortableWorkspaces-Creator-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows To Go 工作区 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", %WinToGo%\Microsoft-Windows-PortableWorkspaces-Creator-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab
	)
)
echo.-------------------------------------------------------------------------------
echo.####集成 Windows To Go 工作区已完成############################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set WinToGo=
set PackageServicePackBuild=
set PackageIndex=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 系统恢复模块
::-------------------------------------------------------------------------------------------
:IntSystemRestore

setlocal

cls
echo.===============================================================================
echo.                     MSMG 工具箱 - 集成 Windows 系统恢复
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置 Windows 系统恢复包路径
if "%SelectedSourceOS%" equ "w7" set "SystemRestore=%SystemRestore%\%SelectedSourceOS%"
if "%SelectedSourceOS%" equ "w10" set "SystemRestore=%SystemRestore%\%SelectedSourceOS%\10.0.%ImageBuild%"

:: 设置软件包服务包内部版本
if "%SelectedSourceOS%" equ "w7"  set PackageServicePackBuild=17514

if "%SelectedSourceOS%" equ "w10" (
	if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
	if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
)

:: 检查 Windows 系统恢复包文件是否存在
if not exist "%SystemRestore%\Microsoft-Windows-SystemRestore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 系统恢复包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-SystemRestore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	if "%SelectedSourceOS%" equ "w7" echo.请复制上述文件到 ^<Packs\SystemRestore\%SelectedSourceOS%^> 文件夹……
	if "%SelectedSourceOS%" equ "w10" echo.请复制上述文件到 ^<Packs\SystemRestore\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 系统恢复包文件是否存在
if not exist "%SystemRestore%\Microsoft-Windows-SystemRestore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 系统恢复包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-SystemRestore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	if "%SelectedSourceOS%" equ "w7" echo.请复制上述文件到 ^<Packs\SystemRestore\%SelectedSourceOS%^> 文件夹……
	if "%SelectedSourceOS%" equ "w10" echo.请复制上述文件到 ^<Packs\SystemRestore\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 系统恢复##############################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 系统恢复##################################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
			
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 系统恢复基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%SystemRestore%\Microsoft-Windows-SystemRestore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 系统恢复 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%SystemRestore%\Microsoft-Windows-SystemRestore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"	
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 系统恢复基础包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%SystemRestore%\Microsoft-Windows-SystemRestore-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 系统恢复 [%ImageDefaultLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%SystemRestore%\Microsoft-Windows-SystemRestore-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
)
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 系统恢复已完成################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set SystemRestore=
set PackageServicePackBuild=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft Edge 经典浏览器模块
::-------------------------------------------------------------------------------------------
:IntEdgeClassic

setlocal

cls
echo.===============================================================================
echo.                 MSMG 工具箱 - 集成 Microsoft Edge 经典浏览器
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置 Edge 经典浏览器包路径
set "EdgeClassic=%EdgeClassic%\10.0.%ImageBuild%"

:: 设置软件包服务包内部版本
if "%ImageBuild%" equ "10240" set "PackageServicePackBuild=16384"
if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"

:: 检查 Microsoft Edge 经典浏览器包文件是否存在
if "%SelectedSourceOS%" equ "w10" if not exist "%EdgeClassic%\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Microsoft Edge 经典浏览器包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\EdgeBrowser\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft Edge 经典浏览器包文件是否存在
if "%SelectedSourceOS%" equ "w10" if not exist "%EdgeClassic%\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Microsoft Edge 经典浏览器包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\EdgeBrowser\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft Edge 经典浏览器#####################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft Edge 经典浏览器#########################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Edge 经典浏览器基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%EdgeClassic%\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Edge 经典浏览器 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%EdgeClassic%\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"

		:: 合并注册表修复以启用集成 Windows 10 累积更新。
		if "%ImageBuild%" lss "17763" (
			for %%j in (EnterpriseS, ServerStandard, ServerDatacenter) do (
				if "%ImageEdition%" equ "%%j" if exist "%InstallMount%\%%i\Windows\servicing\packages\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~*.mum" (
					call :MountImageRegistry "%InstallMount%\%%i"
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.mum" /f >nul
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs.bin.%PackageArchitecture%fre.dep\mergedcomponents\images\client\packages\\" /f >nul
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "Visibility" /t REG_DWORD /d "1" /f >nul
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallTimeHigh" /t REG_DWORD /d "30531506" /f >nul
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallTimeLow" /t REG_DWORD /d "76431985" /f >nul
					reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
					call :UnMountImageRegistry
				)
			)
		
			if "%ImageEdition%" equ "EnterpriseSN" if exist "%InstallMount%\%%i\Windows\servicing\packages\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~*.mum" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs.bin.%PackageArchitecture%fre.dep\mergedcomponents\images\client\packages\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallTimeHigh" /t REG_DWORD /d "30531506" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallTimeLow" /t REG_DWORD /d "76431985" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)
		)		
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Edge 经典浏览器基础包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%EdgeClassic%\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Edge 经典浏览器 [%ImageDefaultLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%EdgeClassic%\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"

	:: 合并注册表修复以启用集成 Windows 10 累积更新。 
	if "%ImageBuild%" lss "17763" (
		for %%j in (EnterpriseS, ServerStandard, ServerDatacenter) do (
			if "%ImageEdition%" equ "%%j" if exist "%InstallMount%\Windows\servicing\packages\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~*.mum" (
				call :MountImageRegistry "%InstallMount%"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs.bin.%PackageArchitecture%fre.dep\mergedcomponents\images\client\packages\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallTimeHigh" /t REG_DWORD /d "30531506" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallTimeLow" /t REG_DWORD /d "76431985" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)
		)

		if "%ImageEdition%" equ "EnterpriseSN" if exist "%InstallMount%\Windows\servicing\packages\Microsoft-Windows-Internet-Browser-Package~31bf3856ad364e35~*.mum" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs.bin.%PackageArchitecture%fre.dep\mergedcomponents\images\client\packages\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallTimeHigh" /t REG_DWORD /d "30531506" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallTimeLow" /t REG_DWORD /d "76431985" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseNEdition~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)
	)
)
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft Edge 浏览器已完成###########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set EdgeClassic=
set PackageServicePackBuild=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft Edge Chromium 浏览器模块
::-------------------------------------------------------------------------------------------
:IntEdgeChromium

setlocal

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 集成 Microsoft Edge Chromium 浏览器
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 检查 Microsoft Edge Chromium 浏览器包文件是否存在
if not exist "%EdgeChromium%\EdgeChromium_%ImageArchitecture%.tpk" (
	echo.Microsoft Edge Chromium 浏览器包文件夹缺少 EdgeChromium_%ImageArchitecture%.tpk 文件……
	echo.
	echo.请复制上述文件到 ^<Packs\EdgeChromium^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft Edge Chromium 浏览器包文件是否存在
if not exist "%EdgeChromium%\EdgeChromium_%ImageArchitecture%.reg" (
	echo.Microsoft Edge Chromium 浏览器包文件夹缺少 EdgeChromium_%ImageArchitecture%.reg 文件……
	echo.
	echo.请复制上述文件到 ^<Packs\EdgeChromium^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft Edge Chromium 浏览器################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft Edge Chromium 浏览器####################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		call :ApplyImage "%EdgeChromium%\EdgeChromium_%ImageArchitecture%.tpk", 1, "%InstallMount%\%%i"

		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Microsoft Edge Chromium 浏览器注册表设置##########################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"
		echo.正在将注册表设置合并到映像注册表……
		call :ImportRegistry2Image "%EdgeChromium%\EdgeChromium_%ImageArchitecture%.reg"
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
		echo.
	)
) else (
	call :ApplyImage "%EdgeChromium%\EdgeChromium_%ImageArchitecture%.tpk", 1, "%InstallMount%"
	echo.-------------------------------------------------------------------------------
	echo.####正在合并 Microsoft Edge Chromium 浏览器注册表设置##########################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"
	echo.正在将注册表设置合并到映像注册表……
	call :ImportRegistry2Image "%EdgeChromium%\EdgeChromium_%ImageArchitecture%.reg"
	echo.正在卸载映像注册表……
	call :UnMountImageRegistry
	echo.
)
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft Edge Chromium 浏览器已完成##################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set EdgeChromium=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 盲文辅助功能模块
::-------------------------------------------------------------------------------------------
:IntBraille

setlocal

cls
echo.===============================================================================
echo.                   MSMG 工具箱 - 集成 Windows 盲文辅助功能
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置盲文包路径
set "Braille=%Braille%\10.0.%ImageBuild%"

:: 设置软件包服务包内部版本
if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 检查 Windows 盲文辅助功能包文件是否存在
if not exist "%Braille%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 盲文辅助功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\Braille\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

call :RemoveFile "%Temp%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
if "%ImageBuild%" geq "17763" copy /y "%Braille%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 盲文辅助功能##########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 盲文辅助功能##############################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%\%%i", "%Braille%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
		if "%ImageBuild%" geq "17763" call :AddPackage "%InstallMount%\%%i", "%Temp%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
	)
) else (
	if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%", "%Braille%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%ImageBuild%" geq "17763" call :AddPackage "%InstallMount%", "%Temp%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
)

call :RemoveFile "%Temp%\Microsoft-Windows-Accessibility-Braille-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 盲文辅助已完成################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Braille=
set PackageServicePackBuild=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows Multimedia Restricted Codecs 模块
::-------------------------------------------------------------------------------------------
:IntMMRC

setlocal

cls
echo.===============================================================================
echo.            MSMG 工具箱 - 集成 Windows Multimedia Restricted Codecs
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置 Multimedia Restricted Codecs 包路径
set "MMRC=%MMRC%\10.0.%ImageBuild%"

:: 设置软件包服务包内部版本
if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"

:: 设置 Multimedia Restricted Codecs 包路径
if not exist "%MMRC%\Multimedia-RestrictedCodecsExt-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows Multimedia Restricted Codecs 包文件夹缺少以下文件……
	echo.
	echo."Multimedia-RestrictedCodecsExt-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MultimediaRestrictedCodecs\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 设置 Multimedia Restricted Codecs 包路径
if not exist "%MMRC%\Multimedia-RestrictedCodecsExt-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows Multimedia Restricted Codecs 包文件夹缺少以下文件……
	echo.
	echo."Multimedia-RestrictedCodecsExt-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MultimediaRestrictedCodecs\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 设置 Multimedia Restricted Codecs 包路径
if "%ImageBuild%" leq "17763" if "%ImageArchitecture%" equ "x64" if not exist "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows Multimedia Restricted Codecs 包文件夹缺少以下文件……
	echo.
	echo."Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MultimediaRestrictedCodecs\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 设置 Multimedia Restricted Codecs 包路径
if "%ImageBuild%" leq "17763" if "%ImageArchitecture%" equ "x64" if not exist "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows Multimedia Restricted Codecs 包文件夹缺少以下文件……
	echo.
	echo."Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MultimediaRestrictedCodecs\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 设置 Multimedia Restricted Codecs 包路径
if "%ImageBuild%" geq "18362" if "%ImageArchitecture%" equ "x64" if not exist "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows Multimedia Restricted Codecs 包文件夹缺少以下文件……
	echo.
	echo."Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MultimediaRestrictedCodecs\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 设置 Multimedia Restricted Codecs 包路径
if "%ImageBuild%" geq "18362" if "%ImageArchitecture%" equ "x64" if not exist "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows Multimedia Restricted Codecs 包文件夹缺少以下文件……
	echo.
	echo."Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MultimediaRestrictedCodecs\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows Multimedia Restricted Codecs##########################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows Multimedia Restricted Codecs##############################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul
 
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows Multimedia Restricted Codecs 基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%MMRC%\Multimedia-RestrictedCodecsExt-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows Multimedia Restricted Codecs [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%MMRC%\Multimedia-RestrictedCodecsExt-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------

		if "%ImageArchitecture%" equ "x64" (
			echo.正在集成 Windows Multimedia Restricted Codecs WOW64 基础包……
			echo.-------------------------------------------------------------------------------
			if "%ImageBuild%" leq "17763" call :AddPackage "%InstallMount%\%%i", "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			if "%ImageBuild%" geq "18362" call :AddPackage "%InstallMount%\%%i", "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows Multimedia Restricted Codecs WOW64 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			if "%ImageBuild%" leq "17763" call :AddPackage "%InstallMount%\%%i", "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
			if "%ImageBuild%" geq "18362" call :AddPackage "%InstallMount%\%%i", "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
		)
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Multimedia Restricted Codecs 基础包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%MMRC%\Multimedia-RestrictedCodecsExt-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Multimedia Restricted Codecs [%ImageDefaultLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%MMRC%\Multimedia-RestrictedCodecsExt-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.-------------------------------------------------------------------------------

	if "%ImageArchitecture%" equ "x64" (
		echo.正在集成 Windows Multimedia Restricted Codecs WOW64 基础包……
		echo.-------------------------------------------------------------------------------
		if "%ImageBuild%" leq "17763" call :AddPackage "%InstallMount%", "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
		if "%ImageBuild%" geq "18362" call :AddPackage "%InstallMount%", "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows Multimedia Restricted Codecs WOW64 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		if "%ImageBuild%" leq "17763" call :AddPackage "%InstallMount%", "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
		if "%ImageBuild%" geq "18362" call :AddPackage "%InstallMount%", "%MMRC%\Multimedia-RestrictedCodecsExt-WOW64-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
)
echo.-------------------------------------------------------------------------------
echo.####集成 Windows Multimedia Restricted Codecs 已完成###########################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set MMRC=
set PackageServicePackBuild=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成适用于 Linux 的 Windows 子系统（WSL）模块
::-------------------------------------------------------------------------------------------
:IntWSL

setlocal

cls
echo.===============================================================================
echo.             MSMG 工具箱 - 集成适用于 Linux 的 Windows 子系统 ^(WSL^)
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置适用于 Linux 的 Windows 子系统（WSL）包路径
set "WSL=%WSL%\10.0.%ImageBuild%"

:: 设置软件包服务包内部版本
if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"

:: 检查适用于 Linux 的 Windows 子系统（WSL）包文件是否存在
if not exist "%WSL%\Microsoft-Windows-Lxss-Optional-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.适用于 Linux 的 Windows 子系统 ^(WSL^) 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Lxss-Optional-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WSL\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查适用于 Linux 的 Windows 子系统（WSL）包文件是否存在
if not exist "%WSL%\Microsoft-Windows-Lxss-Optional-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.适用于 Linux 的 Windows 子系统 ^(WSL^) 包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Lxss-Optional-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\WSL\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成适用于 Linux 的 Windows 子系统^(WSL^)############################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成适用于 Linux 的 Windows 子系统^(WSL^)################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		echo.-------------------------------------------------------------------------------
		echo.正在集成适用于 Linux 的 Windows 子系统 ^(WSL^) 基础包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%WSL%\Microsoft-Windows-Lxss-Optional-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成适用于 Linux 的 Windows 子系统 ^(WSL^) [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%\%%i", "%WSL%\Microsoft-Windows-Lxss-Optional-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成适用于 Linux 的 Windows 子系统 ^(WSL^) 基础包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%WSL%\Microsoft-Windows-Lxss-Optional-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成适用于 Linux 的 Windows 子系统 ^(WSL^) [%ImageDefaultLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%WSL%\Microsoft-Windows-Lxss-Optional-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
)
echo.-------------------------------------------------------------------------------
echo.####正在启用适用于 Linux 的 Windows 子系统 ^(WSL^) 的相关功能####################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.-------------------------------------------------------------------------------
		echo.正在启用映像中的适用于 Linux 的 Windows 子系统 ^(WSL^) 功能……
		echo.-------------------------------------------------------------------------------
		call :EnableFeature "%InstallMount%\%%i", "Microsoft-Windows-Subsystem-Linux /All"
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在启用映像中的适用于 Linux 的 Windows 子系统 ^(WSL^) 功能……
	echo.-------------------------------------------------------------------------------
	call :EnableFeature "%InstallMount%", "Microsoft-Windows-Subsystem-Linux /All"
)
echo.-------------------------------------------------------------------------------
echo.####集成适用于 Linux 的 Windows 子系统 ^(WSL^) 已完成############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set PackageServicePackBuild=
set WSL=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Open Secure Shell（SSH）客户端和服务器端模块
::-------------------------------------------------------------------------------------------
:IntOpenSSH

setlocal

cls
echo.===============================================================================
echo.           MSMG 工具箱 - 集成 Open Secure Shell^(SSH^) 客户端和服务器端
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置 Open Secure Shell 包路径
set "OpenSSH=%OpenSSH%\10.0.%ImageBuild%"

:: 设置软件包服务包内部版本
if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 检查 Open Secure Shell（SSH）客户端包文件是否存在
if not exist "%OpenSSH%\OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.OpenSSH 客户端和服务器端包文件夹缺少以下文件……
	echo.
	echo."OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\OpenSSH\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Open Secure Shell（SSH）服务器端包文件是否存在
if not exist "%OpenSSH%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.OpenSSH 客户端和服务器端包文件夹缺少以下文件……
	echo.
	echo."OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\OpenSSH\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

call :RemoveFile "%Temp%\OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
call :RemoveFile "%Temp%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"

if "%ImageBuild%" geq "17763" (
	copy /y "%OpenSSH%\OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
	copy /y "%OpenSSH%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" "%Temp%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab" >nul
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Open Secure Shell^(SSH^) 客户端和服务器端#######################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Open Secure Shell^(SSH^) 客户端和服务器端###########################
echo.-------------------------------------------------------------------------------

if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.-------------------------------------------------------------------------------
		echo.正在集成 OpenSSH 客户端软件包……
		echo.-------------------------------------------------------------------------------
		if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%\%%i", "%OpenSSH%\OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
		if "%ImageBuild%" geq "17763" call :AddPackage "%InstallMount%\%%i", "%Temp%\OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 OpenSSH 服务器端软件包……
		echo.-------------------------------------------------------------------------------
		if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%\%%i", "%OpenSSH%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
		if "%ImageBuild%" geq "17763" call :AddPackage "%InstallMount%\%%i", "%Temp%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
	)
) else (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 OpenSSH 客户端软件包……
	echo.-------------------------------------------------------------------------------
	if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%", "%OpenSSH%\OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%ImageBuild%" geq "17763" call :AddPackage "%InstallMount%", "%Temp%\OpenSSH-Client-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 OpenSSH 服务器端软件包……
	echo.-------------------------------------------------------------------------------
	if "%ImageBuild%" leq "17134" call :AddPackage "%InstallMount%", "%OpenSSH%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%ImageBuild%" geq "17763" call :AddPackage "%InstallMount%", "%Temp%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
)
call :RemoveFile "%Temp%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
call :RemoveFile "%Temp%\OpenSSH-Server-Package~31bf3856ad364e35~%PackageArchitecture%~~.cab"
echo.-------------------------------------------------------------------------------
echo.####集成 Open Secure Shell^(SSH^) 客户端和服务器端已完成#########################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set OpenSSH=
set PackageServicePackBuild=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 媒体功能包模块
::-------------------------------------------------------------------------------------------
:IntMediaFeaturePack

setlocal

cls
echo.===============================================================================
echo.                    MSMG 工具箱 - 集成 Windows 媒体功能包
echo.===============================================================================
echo.

:: 根据所选源操作系统设置 Windows 媒体功能包的包文件夹路径
if "%SelectedSourceOS%" neq "w10" set "MediaFeaturePack=%MediaFeaturePack%\%SelectedSourceOS%"
if "%SelectedSourceOS%" equ "w10" set "MediaFeaturePack=%MediaFeaturePack%\%SelectedSourceOS%\%ImageVersion%"

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包服务包内部版本
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageBuild%" equ "10240" set "PackageServicePackBuild=16384"
	if "%ImageBuild%" equ "10586" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
	if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
	if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
	if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"
)

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 检查多重索引维护模式是否已启用
if "%ImageIndexNo%" equ "*" (
	echo.当多重索引维护模式已启用时，此功能不可用……
	echo.
	echo.请使用单一的索引重新选择源文件……
	goto :Stop
)

:: 检查所选择的源操作系统是否是 N、K、KN 版本
if "%ImageIndexNo%" neq "*" if "%ImageEdition%" neq "StarterN" if "%ImageEdition%" neq "StarterKN" if "%ImageEdition%" neq "HomeBasicN" if "%ImageEdition%" neq "HomeBasicKN" if "%ImageEdition%" neq "CoreN" if "%ImageEdition%" neq "CloudN" if "%ImageEdition%" neq "ProfessionalN" if "%ImageEdition%" neq "ProfessionalKN" if "%ImageEdition%" neq "ProfessionalEducationN" if "%ImageEdition%" neq "ProfessionalEducationKN" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "EnterpriseKN" if "%ImageEdition%" neq "EnterpriseSN" if "%ImageEdition%" neq "EnterpriseSKN" if "%ImageEdition%" neq "EnterpriseGN" if "%ImageEdition%" neq "UltimateN" if "%ImageEdition%" neq "UltimateKN" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "EducationKN" (
	if "%SelectedSourceOS%" equ "w7" echo.此功能需要 Windows 7 N/K/KN 版……
	if "%SelectedSourceOS%" equ "w81" echo.此功能需要 Windows 8.1 N 版……
	if "%SelectedSourceOS%" equ "w10" echo.此功能需要 Windows 10 N 版……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%MediaFeaturePack%\Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.1.7600.16385.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.1.7600.16385.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%MediaFeaturePack%\Microsoft-Windows-Media-Format-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.1.7600.16385.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Media-Format-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.1.7600.16385.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%MediaFeaturePack%\Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17763" if not exist "%MediaFeaturePack%\Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%\%ImageVersion%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17763" if not exist "%MediaFeaturePack%\Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%\%ImageVersion%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if not exist "%MediaFeaturePack%\Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%\%ImageVersion%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if not exist "%MediaFeaturePack%\Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%\%ImageVersion%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageArchitecture%" equ "x64" if not exist "%MediaFeaturePack%\Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%\%ImageVersion%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 媒体功能包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageArchitecture%" equ "x64" if not exist "%MediaFeaturePack%\Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 媒体功能包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\MediaFeaturePack\%SelectedSourceOS%\%ImageVersion%^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 媒体功能包############################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 媒体功能包################################################
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w7" (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Windows 媒体功能包 OOB 包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%MediaFeaturePack%\Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Windows 媒体格式 OOB 包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%MediaFeaturePack%\Microsoft-Windows-Media-Format-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.1.7600.16385.cab"
)

if "%SelectedSourceOS%" equ "w81" call :AddPackage "%InstallMount%", "%MediaFeaturePack%\Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~6.3.9600.16384.cab"

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" leq "17763" (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Windows 媒体功能包 OOB 包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%MediaFeaturePack%\Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Windows 媒体功能包 OOB [%ImageDefaultLanguage%] 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%MediaFeaturePack%\Microsoft-Windows-MediaFeaturePack-OOB-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
)

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" (
	echo.
	call :RemoveFolder "%Temp%\Updates\MediaFeaturePack"
	call :CreateFolder "%Temp%\Updates\MediaFeaturePack"
	expand -R "%MediaFeaturePack%\Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" -F:* "%Temp%\Updates\MediaFeaturePack" >nul
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Windows 媒体功能软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%Temp%\Updates\MediaFeaturePack"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Windows 媒体功能 [%ImageDefaultLanguage%] 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%MediaFeaturePack%\Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%ImageArchitecture%" equ "x64" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Windows 媒体功能 WOW64 软件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%MediaFeaturePack%\Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Windows 媒体功能 [%ImageDefaultLanguage%] WOW64 软件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%MediaFeaturePack%\Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	)
	call :RemoveFolder "%Temp%\Updates"
)
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 媒体功能包已完成##############################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set MediaFeaturePack=
set PackageServicePackBuild=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 便携设备模块
::-------------------------------------------------------------------------------------------
:IntPortableDevices

setlocal

cls
echo.===============================================================================
echo.                     MSMG 工具箱 - 集成 Windows 便携设备
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置 Windows 便携设备包路径
set "PortableDevices=%PortableDevices%\10.0.%ImageBuild%"

:: 设置软件包服务包内部版本
if "%ImageBuild%" equ "10240" set "PackageServicePackBuild=16384"
if "%ImageBuild%" equ "14393" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "15063" set "PackageServicePackBuild=0"
if "%ImageBuild%" equ "16299" set "PackageServicePackBuild=15"
if "%ImageBuild%" equ "17134" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "17763" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18362" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "18363" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19041" set "PackageServicePackBuild=1"
if "%ImageBuild%" equ "19042" set "PackageServicePackBuild=1"

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"

:: 检查多重索引维护模式是否已启用
if "%ImageIndexNo%" equ "*" (
	echo.当多重索引维护模式已启用时，此功能不可用……
	echo.
	echo.请使用单一的索引重新选择源文件……
	goto :Stop
)

:: 检查所选择的源操作系统是否是 N、K、KN 版本
if "%ImageIndexNo%" neq "*" if "%ImageEdition%" neq "StarterN" if "%ImageEdition%" neq "StarterKN" if "%ImageEdition%" neq "HomeBasicN" if "%ImageEdition%" neq "HomeBasicKN" if "%ImageEdition%" neq "CoreN" if "%ImageEdition%" neq "CloudN" if "%ImageEdition%" neq "ProfessionalN" if "%ImageEdition%" neq "ProfessionalKN" if "%ImageEdition%" neq "ProfessionalEducationN" if "%ImageEdition%" neq "ProfessionalEducationKN" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "EnterpriseKN" if "%ImageEdition%" neq "EnterpriseSN" if "%ImageEdition%" neq "EnterpriseSKN" if "%ImageEdition%" neq "EnterpriseGN" if "%ImageEdition%" neq "UltimateN" if "%ImageEdition%" neq "UltimateKN" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "EducationKN" (
	if "%SelectedSourceOS%" equ "w7" echo.此功能需要 Windows 7 N/K/KN 版……
	if "%SelectedSourceOS%" equ "w81" echo.此功能需要 Windows 8.1 N 版……
	if "%SelectedSourceOS%" equ "w10" echo.此功能需要 Windows 10 N 版……
	goto :Stop
)

:: 检查 Windows 便携设备包文件是否存在
if not exist "%PortableDevices%\Microsoft-Windows-Portable-Devices-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 便携设备包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Portable-Devices-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\PortableDevices\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 便携设备包文件是否存在
if not exist "%PortableDevices%\Microsoft-Windows-Portable-Devices-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 便携设备包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Portable-Devices-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\PortableDevices\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 便携设备包文件是否存在
if "%ImageBuild%" leq "17763" if "%ImageArchitecture%" equ "x64" if not exist "%PortableDevices%\Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 便携设备包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\PortableDevices\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 便携设备包文件是否存在
if "%ImageBuild%" leq "17763" if "%ImageArchitecture%" equ "x64" if not exist "%PortableDevices%\Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 便携设备包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\PortableDevices\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 便携设备包文件是否存在
if "%ImageBuild%" geq "18362" if "%ImageArchitecture%" equ "x64" if not exist "%PortableDevices%\Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 便携设备包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\PortableDevices\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 便携设备包文件是否存在
if "%ImageBuild%" geq "18362" if "%ImageArchitecture%" equ "x64" if not exist "%PortableDevices%\Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab" (
	echo.Windows 便携设备包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\PortableDevices\10.0.%ImageBuild%^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 便携设备##############################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 便携设备##################################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在集成 Windows 便携设备软件包……
echo.-------------------------------------------------------------------------------
call :AddPackage "%InstallMount%", "%PortableDevices%\Microsoft-Windows-Portable-Devices-Package~31bf3856ad364e35~%PackageArchitecture%~~%ImageVersion%.%PackageServicePackBuild%.cab"
echo.-------------------------------------------------------------------------------
echo.正在集成 Windows 便携设备 [%ImageDefaultLanguage%] 语言包……
echo.-------------------------------------------------------------------------------
call :AddPackage "%InstallMount%", "%PortableDevices%\Microsoft-Windows-Portable-Devices-Package~31bf3856ad364e35~%PackageArchitecture%~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"

if "%ImageArchitecture%" equ "x64" (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 便携设备 WOW64 软件包……
	echo.-------------------------------------------------------------------------------
	if "%ImageBuild%" leq "17763" call :AddPackage "%InstallMount%", "%PortableDevices%\Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~amd64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%ImageBuild%" geq "18362" call :AddPackage "%InstallMount%", "%PortableDevices%\Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~wow64~~%ImageVersion%.%PackageServicePackBuild%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 便携设备 [%ImageDefaultLanguage%] 语言 WOW64 软件包……
	echo.-------------------------------------------------------------------------------
	if "%ImageBuild%" leq "17763" call :AddPackage "%InstallMount%", "%PortableDevices%\Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~amd64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
	if "%ImageBuild%" geq "18362" call :AddPackage "%InstallMount%", "%PortableDevices%\Microsoft-Windows-Portable-Devices-WOW64-Package~31bf3856ad364e35~wow64~%ImageDefaultLanguage%~%ImageVersion%.%PackageServicePackBuild%.cab"
)

echo.-------------------------------------------------------------------------------
echo.####集成 Windows 便携设备已完成################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set PortableDevices=
set PackageServicePackBuild=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows PowerShell 7.0 模块
::-------------------------------------------------------------------------------------------
:IntPowerShell7

setlocal

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 集成 Windows PowerShell 7.0
echo.===============================================================================
echo.
:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 检查 Windows PowerShell 7.0 包文件是否存在
if not exist "%PowerShell7%\PowerShell7_%SelectedSourceOS%.tpk" (
	echo.Windows PowerShell 7.0 包文件夹缺少以下文件……
	echo.
	echo."PowerShell7_%SelectedSourceOS%.tpk"
	echo.
	echo.请复制上述文件到 ^<Packs\PowerShell7^> 文件夹……
	goto :Stop
)

:: 检查 Windows PowerShell 7.0 包文件是否存在
if not exist "%PowerShell7%\PowerShell7_w7_%ImageArchitecture%.reg" (
	echo.Windows PowerShell 7.0 包文件夹缺少以下文件……
	echo.
	echo."PowerShell7_w7_%ImageArchitecture%.reg"
	echo.
	echo.请复制上述文件到 ^<Packs\PowerShell7^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows PowerShell 7.0########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows PowerShell 7.0############################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		if "%ImageArchitecture%" equ "x86" call :ApplyImage "%PowerShell7%\PowerShell7_%SelectedSourceOS%.tpk", 1, "%InstallMount%\%%i"
		if "%ImageArchitecture%" equ "x64" call :ApplyImage "%PowerShell7%\PowerShell7_%SelectedSourceOS%.tpk", 2, "%InstallMount%\%%i"
		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Windows PowerShell 7.0 注册表设置#################################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"	
		echo.正在将注册表设置合并到映像注册表……
		call :ImportRegistry2Image "%PowerShell7%\PowerShell7_w7_%ImageArchitecture%.reg"		
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
	)
) else (
	if "%ImageArchitecture%" equ "x86" call :ApplyImage "%PowerShell7%\PowerShell7_%SelectedSourceOS%.tpk", 1, "%InstallMount%"
	if "%ImageArchitecture%" equ "x64" call :ApplyImage "%PowerShell7%\PowerShell7_%SelectedSourceOS%.tpk", 2, "%InstallMount%"
	echo.-------------------------------------------------------------------------------
	echo.####正在合并 Windows PowerShell 7.0 注册表设置#################################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"
	echo.正在将注册表设置合并到映像注册表……
	call :ImportRegistry2Image "%PowerShell7%\PowerShell7_w7_%ImageArchitecture%.reg"	
	echo.正在卸载映像注册表……
	call :UnMountImageRegistry
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Windows PowerShell 7.0 已完成#########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set PowerShell7=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 远程服务器管理工具（RSAT）模块
::-------------------------------------------------------------------------------------------
:IntRSAT

setlocal

set RSATType=

if "%SelectedSourceOS%" equ "w10" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Windows 远程服务器管理工具 ^(RSAT^)
	echo.===============================================================================
	echo.
	echo.  [1]  适用于管理目标版本早于 Windows Server 版本 1709 的 RSAT
	echo.
	echo.  [2]  适用于管理 Windows Server 版本 1709 的 RSAT
	echo.
	echo.  [3]  适用于管理 Windows Server 版本 1803 的 RSAT
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :IntegrateMenu
	if errorlevel 3 set RSATType=v1803
	if errorlevel 2 set RSATType=v1709
	if errorlevel 1 set RSATType=v1609
)

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 集成 Windows 远程服务器管理工具 ^(RSAT^)
echo.===============================================================================
echo.

:: 根据所选源操作系统设置 Windows 远程服务器管理工具（RSAT）包文件夹路径
set "RSAT=%RSAT%\%SelectedSourceOS%"

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"

:: 检查 Windows 远程服务器管理工具（RSAT）包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%RSAT%\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.远程服务器管理工具包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RSAT\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查适用于流媒体服务的 Windows 远程服务器管理工具（RSAT）包文件是否存在
if "%SelectedSourceOS%" equ "w7" if not exist "%RSAT%\Microsoft-Windows-MediaServer-Admin-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.远程服务器管理工具包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-MediaServer-Admin-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RSAT\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 远程服务器管理工具（RSAT）包文件是否存在
if "%SelectedSourceOS%" equ "w81" if not exist "%RSAT%\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab" (
	echo.远程服务器管理工具包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RSAT\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Windows 远程服务器管理工具（RSAT）包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%RSATType%" equ "v1609" if not exist "%RSAT%\10.0.14393\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.cab" (
	echo.远程服务器管理工具包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RSAT\%SelectedSourceOS%\10.0.14393^> 文件夹……
	goto :Stop
)

:: 检查 Windows 远程服务器管理工具（RSAT）包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%RSATType%" equ "v1709" if not exist "%RSAT%\10.0.16299\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.cab" (
	echo.远程服务器管理工具包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RSAT\%SelectedSourceOS%\10.0.16299^> 文件夹……
	goto :Stop
)

:: 检查 Windows 远程服务器管理工具（RSAT）包文件是否存在
if "%SelectedSourceOS%" equ "w10" if "%RSATType%" equ "v1803" if not exist "%RSAT%\10.0.17134\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.17134.1.cab" (
	echo.远程服务器管理工具包文件夹缺少以下文件……
	echo.
	echo."Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.17134.1.cab"
	echo.
	echo.请复制上述文件到 ^<Packs\RSAT\%SelectedSourceOS%\10.0.17134^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 远程服务器管理工具 ^(RSAT^)#############################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 远程服务器管理工具 ^(RSAT^)#################################
echo.-------------------------------------------------------------------------------

if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		:: 检查所选择的源操作系统是否是有效的版本
		if "%SelectedSourceOS%" equ "w7" if "!ImageEdition:~,12!" neq "Professional" if "!ImageEdition:~,8!" neq "Ultimate" (
			echo.
			echo.此功能需要 Windows 7 专业版或旗舰版……
			echo.
			echo.-------------------------------------------------------------------------------
			echo.####正在跳过集成 Windows 远程服务器管理工具 ^(RSAT^)#############################
			echo.-------------------------------------------------------------------------------
			echo.
		)
		if "%SelectedSourceOS%" neq "w7" if "!ImageEdition:~,12!" neq "Professional" if "!ImageEdition:~,10!" neq "Enterprise" (
			echo.
			if "%SelectedSourceOS%" equ "w81" echo.此功能需要 Windows 8.1 专业版或企业版……
			if "%SelectedSourceOS%" equ "w10" echo.此功能需要 Windows 10 专业版或企业版……
			echo.
			echo.-------------------------------------------------------------------------------
			echo.####正在跳过集成 Windows 远程服务器管理工具 ^(RSAT^)#############################
			echo.-------------------------------------------------------------------------------
			echo.
		)

		if "%SelectedSourceOS%" equ "w7" if "!ImageEdition:~,7!" neq "Starter" if "!ImageEdition:~,9!" neq "HomeBasic" if "!ImageEdition:~,11!" neq "HomePremium" if "!ImageEdition:~,6!" neq "Server" (
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 远程服务器管理工具 ^(RSAT^) 软件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%RSAT%\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成适用于流媒体服务的 Windows RSAT 软件包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%RSAT%\Microsoft-Windows-MediaServer-Admin-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
		)

		if "%SelectedSourceOS%" equ "w81" if "!ImageEdition!" neq "Core" if "!ImageEdition!" neq "CoreN" if "!ImageEdition!" neq "CoreSingleLanguage" if "!ImageEdition:~,6!" neq "Server" (
			call :AddPackage "%InstallMount%\%%i", "%RSAT%\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
		)

		if "%SelectedSourceOS%" equ "w10" if "!ImageEdition!" neq "Core" if "!ImageEdition!" neq "CoreN" if "!ImageEdition!" neq "CoreSingleLanguage" if "!ImageEdition!" neq "Education" if "!ImageEdition!" neq "EducationN" if "!ImageEdition!" neq "ProfessionalEducation" if "!ImageEdition!" neq "ProfessionalEducationN" if "!ImageEdition!" neq "Cloud" if "!ImageEdition!" neq "CloudN" if "!ImageEdition:~,6!" neq "Server" (
			if "%RSATType%" equ "v1609" call :AddPackage "%InstallMount%\%%i", "%RSAT%\10.0.14393\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.cab"
			if "%RSATType%" equ "v1709" call :AddPackage "%InstallMount%\%%i", "%RSAT%\10.0.16299\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.cab"
			if "%RSATType%" equ "v1803" call :AddPackage "%InstallMount%\%%i", "%RSAT%\10.0.17134\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.17134.1.cab"
		)
	)
) else (
	:: 检查所选择的源操作系统是否是有效的版本
	if "%SelectedSourceOS%" equ "w7" if "%ImageEdition:~,12%" neq "Professional" if "%ImageEdition:~,8%" neq "Ultimate" (
		echo.
		echo.此功能需要 Windows 7 专业版或旗舰版……
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####正在跳过集成 Windows 远程服务器管理工具 ^(RSAT^)#############################
		echo.-------------------------------------------------------------------------------
		goto :Stop
	)

	if "%SelectedSourceOS%" neq "w7" if "!ImageEdition:~,12!" neq "Professional" if "!ImageEdition:~,10!" neq "Enterprise" (
		echo.
		if "%SelectedSourceOS%" equ "w81" echo.此功能需要 Windows 8.1 专业版或企业版……
		if "%SelectedSourceOS%" equ "w10" echo.此功能需要 Windows 10 专业版或企业版……
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####正在跳过集成 Windows 远程服务器管理工具 ^(RSAT^)#############################
		echo.-------------------------------------------------------------------------------
		goto :Stop
	)

	if "%SelectedSourceOS%" equ "w7" if "!ImageEdition:~,7!" neq "Starter" if "!ImageEdition:~,9!" neq "HomeBasic" if "!ImageEdition:~,11!" neq "HomePremium" if "!ImageEdition:~,6!" neq "Server" (
		echo.
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 远程服务器管理工具 ^(RSAT^) 软件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%RSAT%\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成适用于流媒体服务的 Windows RSAT 软件包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%RSAT%\Microsoft-Windows-MediaServer-Admin-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
	)
	
	if "%SelectedSourceOS%" equ "w81" if "!ImageEdition!" neq "Core" if "!ImageEdition!" neq "CoreN" if "!ImageEdition!" neq "CoreSingleLanguage" if "!ImageEdition:~,6!" neq "Server" (
		call :AddPackage "%InstallMount%", "%RSAT%\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%.cab"
	)

	if "%SelectedSourceOS%" equ "w10" if "!ImageEdition!" neq "Core" if "!ImageEdition!" neq "CoreN" if "!ImageEdition!" neq "CoreSingleLanguage" if "!ImageEdition!" neq "Education" if "!ImageEdition!" neq "EducationN" if "!ImageEdition!" neq "ProfessionalEducation" if "!ImageEdition!" neq "ProfessionalEducationN" if "!ImageEdition!" neq "Cloud" if "!ImageEdition!" neq "CloudN" if "!ImageEdition:~,6!" neq "Server" (
		if "%RSATType%" equ "v1609" call :AddPackage "%InstallMount%", "%RSAT%\10.0.14393\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.cab"
		if "%RSATType%" equ "v1709" call :AddPackage "%InstallMount%", "%RSAT%\10.0.16299\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.cab"
		if "%RSATType%" equ "v1803" call :AddPackage "%InstallMount%", "%RSAT%\10.0.17134\Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel~31bf3856ad364e35~%PackageArchitecture%~~10.0.17134.1.cab"
	)
)
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 远程服务器管理工具 ^(RSAT^) 已完成##############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set RSAT=
set RSATType=
set PackageArchitecture=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 集成默认 Metro 应用
::-------------------------------------------------------------------------------------------
:IntMetroApps

setlocal

set MetroApp=

set Alarms_Appx=
set AppConnector_Appx=
set BingFinance_Appx=
set BingFoodDrink_Appx=
set BingHealthFitness_Appx=
set BingMaps_Appx=
set BingNews_Appx=
set BingSports_Appx=
set BingTravel_Appx=
set BingWeather_Appx=
set Calculator_Appx=
set Camera_Appx=
set CommunicationsApps_Appx=
set DesktopAppInstaller_Appx=
set FeedbackHub_Appx=
set GetHelp_Appx=
set Getstarted_Appx=
set HEIFImageExtension_arm_Appx=
set HEIFImageExtension_x86_Appx=
set HEIFImageExtension_x64_Appx=
set HEVCVideoExtension_arm_Appx=
set HEVCVideoExtension_x86_Appx=
set HEVCVideoExtension_x64_Appx=
set HelpAndTips_Appx=
set Maps_Appx=
set Messaging_Appx=
set MixedRealityPortal_Appx=
set MPEG2VideoExtension_arm_Appx=
set MPEG2VideoExtension_x86_Appx=
set MPEG2VideoExtension_x64_Appx=
set OfficeHub_Appx=
set OfficeOneNote_Appx=
set OfficeSway_Appx=
set OneConnect_Appx=
set Paint3D_Appx=
set People_Appx=
set Phone_Appx=
set PhoneCompanion_Appx=
set Photos_Appx=
set Print3D_Appx=
set Reader_Appx=
set ReadingList_Appx=
set Scan_Appx=
set ScreenSketch_Appx=
set Skype_Appx=
set SolitaireCollection_Appx=
set SoundRecorder_Appx=
set StickyNotes_Appx=
set Store_Appx=
set StorePurchase_Appx=
set ThreeDBuilder_Appx=
set ThreeDViewer_Appx=
set VP9VideoExtensions_arm_Appx=
set VP9VideoExtensions_x86_Appx=
set VP9VideoExtensions_x64_Appx=
set Wallet_Appx=
set WebMediaExtensions_Appx=
set WebpImageExtension_arm_Appx=
set WebpImageExtension_x86_Appx=
set WebpImageExtension_x64_Appx=
set WiFi_Appx=
set Xbox_Appx=
set XboxGameOverlay_Appx=
set XboxGamingOverlay_Appx=
set XboxIdentityProvider_Appx=
set XboxLiveGames_Appx=
set XboxSpeechToTextOverlay_Appx=
set XboxTCUI_Appx=
set YourPhone_Appx=
set ZuneMusic_Appx=
set ZuneVideo_Appx=

set Alarms_License=
set AppConnector_License=
set BingFinance_License=
set BingFoodDrink_License=
set BingHealthFitness_License=
set BingMaps_License=
set BingNews_License=
set BingSports_License=
set BingTravel_License=
set BingWeather_License=
set Calculator_License=
set Camera_License=
set CommunicationsApps_License=
set DesktopAppInstaller_License=
set FeedbackHub_License=
set GetHelp_License=
set Getstarted_License=
set HEIFImageExtension_arm_License=
set HEIFImageExtension_x86_License=
set HEIFImageExtension_x64_License=
set HEVCVideoExtension_arm_License=
set HEVCVideoExtension_x86_License=
set HEVCVideoExtension_x64_License=
set HelpAndTips_License=
set Maps_License=
set Messaging_License=
set MixedRealityPortal_License=
set MPEG2VideoExtension_arm_License=
set MPEG2VideoExtension_x86_License=
set MPEG2VideoExtension_x64_License=
set OfficeHub_License=
set OfficeOneNote_License=
set OfficeSway_License=
set OneConnect_License=
set Paint3D_License=
set People_License=
set Phone_License=
set PhoneCompanion_License=
set Photos_License=
set Print3D_License=
set Reader_License=
set ReadingList_License=
set Scan_License=
set ScreenSketch_License=
set Skype_License=
set SolitaireCollection_License=
set SoundRecorder_License=
set StickyNotes_License=
set Store_License=
set StorePurchase_License=
set ThreeDBuilder_License=
set ThreeDViewer_License=
set VP9VideoExtensions_arm_License=
set VP9VideoExtensions_x86_License=
set VP9VideoExtensions_x64_License=
set Wallet_License=
set WebMediaExtensions_License=
set WebpImageExtension_arm_License=
set WebpImageExtension_x86_License=
set WebpImageExtension_x64_License=
set WiFi_License=
set Xbox_License=
set XboxGameOverlay_License=
set XboxGamingOverlay_License=
set XboxIdentityProvider_License=
set XboxLiveGames_License=
set XboxSpeechToTextOverlay_License=
set XboxTCUI_License=
set YourPhone_License=
set ZuneMusic_License=
set ZuneVideo_License=

set DependencyPackagePath=

set AdvertisingXaml_arm_Appx=
set AdvertisingXaml_arm64_Appx=
set AdvertisingXaml_x86_Appx=
set AdvertisingXaml_x64_Appx=
set MediaPlayReadyClient22_arm_Appx=
set MediaPlayReadyClient22_x86_Appx=
set MediaPlayReadyClient22_x64_Appx=
set NETNativeFramework13_arm_Appx=
set NETNativeFramework13_x86_Appx=
set NETNativeFramework13_x64_Appx=
set NETNativeFramework16_arm_Appx=
set NETNativeFramework16_x86_Appx=
set NETNativeFramework16_x64_Appx=
set NETNativeFramework17_arm_Appx=
set NETNativeFramework17_x86_Appx=
set NETNativeFramework17_x64_Appx=
set NETNativeFramework21_arm_Appx=
set NETNativeFramework21_x86_Appx=
set NETNativeFramework21_x64_Appx=
set NETNativeFramework22_arm_Appx=
set NETNativeFramework22_arm64_Appx=
set NETNativeFramework22_x86_Appx=
set NETNativeFramework22_x64_Appx=
set NETNativeRuntime13_arm_Appx=
set NETNativeRuntime13_x86_Appx=
set NETNativeRuntime13_x64_Appx=
set NETNativeRuntime14_arm_Appx=
set NETNativeRuntime14_x86_Appx=
set NETNativeRuntime14_x64_Appx=
set NETNativeRuntime16_arm_Appx=
set NETNativeRuntime16_x86_Appx=
set NETNativeRuntime16_x64_Appx=
set NETNativeRuntime17_arm_Appx=
set NETNativeRuntime17_x86_Appx=
set NETNativeRuntime17_x64_Appx=
set NETNativeRuntime21_arm_Appx=
set NETNativeRuntime21_x86_Appx=
set NETNativeRuntime21_x64_Appx=
set NETNativeRuntime22_arm_Appx=
set NETNativeRuntime22_arm64_Appx=
set NETNativeRuntime22_x86_Appx=
set NETNativeRuntime22_x64_Appx=
set ServicesStoreEngagement_arm_Appx=
set ServicesStoreEngagement_arm64_Appx=
set ServicesStoreEngagement_x86_Appx=
set ServicesStoreEngagement_x64_Appx=
set UIXaml20_arm_Appx=
set UIXaml20_arm64_Appx=
set UIXaml20_x86_Appx=
set UIXaml20_x64_Appx=
set UIXaml21_arm_Appx=
set UIXaml21_arm64_Appx=
set UIXaml21_x86_Appx=
set UIXaml21_x64_Appx=
set VCLibs12_arm_Appx=
set VCLibs12_x86_Appx=
set VCLibs12_x64_Appx=
set VCLibs14_arm_Appx=
set VCLibs14_arm64_Appx=
set VCLibs14_x86_Appx=
set VCLibs14_x64_Appx=
set VCLibsUWPDesktop14_arm_Appx=
set VCLibsUWPDesktop14_arm64_Appx=
set VCLibsUWPDesktop14_x86_Appx=
set VCLibsUWPDesktop14_x64_Appx=
set WinJS20_Appx=

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用
echo.===============================================================================
echo.

:: 集成 Windows 8.1 默认 Metro 应用菜单
if "%SelectedSourceOS%" equ "w81" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用菜单
	echo.===============================================================================
	echo.                                  ^|
	echo.  [A]  闹钟                       ^| [R]  录音机
	echo.  [B]  计算器                     ^| [S]  Xbox LIVE 游戏
	echo.  [C]  日历、邮件和人脉           ^| [T]  Zune 音乐
	echo.  [D]  Bing 财经                  ^| [U]  Zune 视频
	echo.  [E]  Bing 美食                  ^|
	echo.  [F]  Bing 健康                  ^|
	echo.  [G]  Bing 地图                  ^|
	echo.  [H]  Bing 资讯                  ^|
	echo.  [I]  Bing 体育                  ^|
	echo.  [J]  Bing 旅游                  ^|
	echo.  [K]  Bing 天气                  ^|
	echo.  [L]  帮助和提示                 ^|
	echo.  [M]  Office OneNote             ^|
	echo.  [N]  阅读器                     ^|
	echo.  [O]  阅读列表                   ^|
	echo.  [P]  扫描                       ^| [1]  所有应用
	echo.  [Q]  Skype                      ^| [X]  返回
	echo.                                  ^|
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQRSTU1X /N /M "请输入你的选项 ："
	if errorlevel 23 goto :IntFeatures
	if errorlevel 22 set "MetroApp=AllApps"
	if errorlevel 21 set "MetroApp=ZuneVideo"
	if errorlevel 20 set "MetroApp=ZuneMusic"
	if errorlevel 19 set "MetroApp=XboxLiveGames"
	if errorlevel 18 set "MetroApp=SoundRecorder"
	if errorlevel 17 set "MetroApp=SkypeApp"
	if errorlevel 16 set "MetroApp=Scan"
	if errorlevel 15 set "MetroApp=ReadingList"
	if errorlevel 14 set "MetroApp=Reader"
	if errorlevel 13 set "MetroApp=OfficeOneNote"
	if errorlevel 12 set "MetroApp=HelpAndTips"
	if errorlevel 11 set "MetroApp=BingWeather"
	if errorlevel 10 set "MetroApp=BingTravel"
	if errorlevel 9  set "MetroApp=BingSports"
	if errorlevel 8  set "MetroApp=BingNews"
	if errorlevel 7  set "MetroApp=BingMaps"
	if errorlevel 6  set "MetroApp=BingHealthFitness"
	if errorlevel 5  set "MetroApp=BingFoodDrink"
	if errorlevel 4  set "MetroApp=BingFinance"
	if errorlevel 3  set "MetroApp=CommunicationsApps"
	if errorlevel 2  set "MetroApp=Calculator"
	if errorlevel 1  set "MetroApp=Alarms"
)

:: 集成 Windows 10 v1507 默认 Metro 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10240" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用菜单
	echo.===============================================================================
	echo.                                    ^|
	echo.  [A]  3D Builder                   ^|  [R]  人脉
	echo.  [B]  闹钟和时钟                   ^|  [S]  手机助手
	echo.  [C]  应用连接器                   ^|  [T]  照片
	echo.  [D]  Bing 财经                    ^|  [U]  Solitaire Collection
	echo.  [E]  Bing 资讯                    ^|  [V]  应用商店
	echo.  [F]  Bing 体育                    ^|  [W]  录音机
	echo.  [G]  Bing 天气                    ^|  [X]  Xbox 应用
	echo.  [H]  计算器                       ^|
	echo.  [I]  日历和邮件                   ^|
	echo.  [J]  相机                         ^|
	echo.  [K]  获取 Office 应用             ^|
	echo.  [L]  入门                         ^|
	echo.  [M]  获取 Skype 应用              ^|
	echo.  [N]  Groove 音乐                  ^|
	echo.  [O]  地图                         ^|
	echo.  [P]  电影和电视                   ^|  [1]  所有应用
	echo.  [Q]  Office OneNote               ^|  [2]  返回
	echo.                                    ^|
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWX12 /N /M "请输入你的选项 ："
	if errorlevel 26 goto :IntFeatures
	if errorlevel 25 set "MetroApp=AllApps"
	if errorlevel 24 set "MetroApp=XboxApp"
	if errorlevel 23 set "MetroApp=SoundRecorder"
	if errorlevel 22 set "MetroApp=Store"
	if errorlevel 21 set "MetroApp=SolitaireCollection"
	if errorlevel 20 set "MetroApp=Photos"
	if errorlevel 19 set "MetroApp=PhoneCompanion"
	if errorlevel 18 set "MetroApp=People"
	if errorlevel 17 set "MetroApp=OfficeOneNote"
	if errorlevel 16 set "MetroApp=ZuneVideo"
	if errorlevel 15 set "MetroApp=Maps"
	if errorlevel 14 set "MetroApp=ZuneMusic"
	if errorlevel 13 set "MetroApp=SkypeApp"
	if errorlevel 12 set "MetroApp=Getstarted"
	if errorlevel 11 set "MetroApp=OfficeHub"
	if errorlevel 10 set "MetroApp=Camera"
	if errorlevel 9  set "MetroApp=CommunicationsApps"
	if errorlevel 8  set "MetroApp=Calculator"
	if errorlevel 7  set "MetroApp=BingWeather"	
	if errorlevel 6  set "MetroApp=BingSports"
	if errorlevel 5  set "MetroApp=BingNews"
	if errorlevel 4  set "MetroApp=BingFinance"
	if errorlevel 3  set "MetroApp=AppConnector"
	if errorlevel 2  set "MetroApp=Alarms"
	if errorlevel 1  set "MetroApp=ThreeDBuilder"
)

:: 集成 Windows 10 v1511 默认 Metro 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10586" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用菜单
	echo.===============================================================================
	echo.                                    ^|
	echo.  [A]  3D Builder                   ^|  [R]  Office OneNote
	echo.  [B]  闹钟和时钟                   ^|  [S]  Office Sway
	echo.  [C]  应用连接器                   ^|  [T]  人脉
	echo.  [D]  Bing 财经                    ^|  [U]  电话
	echo.  [E]  Bing 资讯                    ^|  [V]  手机助手
	echo.  [F]  Bing 体育                    ^|  [W]  照片
	echo.  [G]  Bing 天气                    ^|  [X]  Solitaire Collection
	echo.  [H]  计算器                       ^|  [Y]  应用商店
	echo.  [I]  日历和邮件                   ^|  [Z]  录音机
	echo.  [J]  相机                         ^|  [1]  Xbox 应用
	echo.  [K]  获取 Office 应用             ^|  [2]  WiFi
	echo.  [L]  入门                         ^|
	echo.  [M]  获取 Skype 应用              ^|
	echo.  [N]  Groove 音乐                  ^|
	echo.  [O]  地图                         ^|
	echo.  [P]  消息                         ^|  [3]  所有应用
	echo.  [Q]  电影和电视                   ^|  [4]  返回
	echo.                                    ^|
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ1234 /N /M "请输入你的选项 ："
	if errorlevel 30 goto :IntFeatures
	if errorlevel 29 set "MetroApp=AllApps"
	if errorlevel 28 set "MetroApp=WiFi"
	if errorlevel 27 set "MetroApp=XboxApp"
	if errorlevel 26 set "MetroApp=SoundRecorder"
	if errorlevel 25 set "MetroApp=Store"
	if errorlevel 24 set "MetroApp=SolitaireCollection"
	if errorlevel 23 set "MetroApp=Photos"
	if errorlevel 22 set "MetroApp=PhoneCompanion"
	if errorlevel 21 set "MetroApp=Phone"
	if errorlevel 20 set "MetroApp=People"
	if errorlevel 19 set "MetroApp=OfficeSway"
	if errorlevel 18 set "MetroApp=OfficeOneNote"
	if errorlevel 17 set "MetroApp=ZuneVideo"
	if errorlevel 16 set "MetroApp=Messaging"
	if errorlevel 15 set "MetroApp=Maps"
	if errorlevel 14 set "MetroApp=ZuneMusic"
	if errorlevel 13 set "MetroApp=SkypeApp"
	if errorlevel 12 set "MetroApp=Getstarted"
	if errorlevel 11 set "MetroApp=OfficeHub"
	if errorlevel 10 set "MetroApp=Camera"
	if errorlevel 9  set "MetroApp=CommunicationsApps"
	if errorlevel 8  set "MetroApp=Calculator"
	if errorlevel 7  set "MetroApp=BingWeather"	
	if errorlevel 6  set "MetroApp=BingSports"
	if errorlevel 5  set "MetroApp=BingNews"
	if errorlevel 4  set "MetroApp=BingFinance"
	if errorlevel 3  set "MetroApp=AppConnector"
	if errorlevel 2  set "MetroApp=Alarms"
	if errorlevel 1  set "MetroApp=ThreeDBuilder"
)

:: 集成 Windows 10 v1607 默认 Metro 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用菜单
	echo.===============================================================================
	echo.                                    ^|
	echo.  [A]  3D Builder                   ^|  [R]  Skype 预览版应用
	echo.  [B]  闹钟和时钟                   ^|  [S]  Solitaire Collection
	echo.  [C]  计算器                       ^|  [T]  便笺
	echo.  [D]  日历和邮件                   ^|  [U]  应用商店
	echo.  [E]  相机                         ^|  [V]  应用商店购买应用
	echo.  [F]  桌面应用安装程序             ^|  [W]  录音机
	echo.  [G]  反馈中心                     ^|  [X]  天气
	echo.  [H]  获取 Office 应用             ^|  [Y]  Xbox 应用
	echo.  [I]  入门                         ^|  [Z]  Xbox Identity Provider
	echo.  [J]  Groove 音乐                  ^|
	echo.  [K]  地图                         ^|
	echo.  [L]  消息                         ^|
	echo.  [M]  电影和电视                   ^|
	echo.  [N]  Office OneNote               ^|
	echo.  [O]  付费 Wi-Fi 和蜂窝数据        ^|
	echo.  [P]  人脉                         ^|  [1]  所有应用
	echo.  [Q]  照片                         ^|  [2]  返回
	echo.                                    ^|
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ12 /N /M "请输入你的选项 ："
	if errorlevel 28 goto :IntFeatures
	if errorlevel 27 set "MetroApp=AllApps"  
	if errorlevel 26 set "MetroApp=XboxIdentityProvider"
	if errorlevel 25 set "MetroApp=XboxApp"
	if errorlevel 24 set "MetroApp=BingWeather"
	if errorlevel 23 set "MetroApp=SoundRecorder"
	if errorlevel 22 set "MetroApp=StorePurchaseApp"
	if errorlevel 21 set "MetroApp=Store"
	if errorlevel 20 set "MetroApp=StickyNotes"
	if errorlevel 19 set "MetroApp=SolitaireCollection"
	if errorlevel 18 set "MetroApp=SkypeApp"	
	if errorlevel 17 set "MetroApp=Photos"
	if errorlevel 16 set "MetroApp=People"
	if errorlevel 15 set "MetroApp=OneConnect"
	if errorlevel 14 set "MetroApp=OfficeOneNote"
	if errorlevel 13 set "MetroApp=ZuneVideo"
	if errorlevel 12 set "MetroApp=Messaging"
	if errorlevel 11 set "MetroApp=Maps"
	if errorlevel 10 set "MetroApp=ZuneMusic"
	if errorlevel 9  set "MetroApp=Getstarted"
	if errorlevel 8  set "MetroApp=OfficeHub"
	if errorlevel 7  set "MetroApp=FeedbackHub"
	if errorlevel 6  set "MetroApp=DesktopAppInstaller"	
	if errorlevel 5  set "MetroApp=Camera"
	if errorlevel 4  set "MetroApp=CommunicationsApps"
	if errorlevel 3  set "MetroApp=Calculator"
	if errorlevel 2  set "MetroApp=Alarms"
	if errorlevel 1  set "MetroApp=ThreeDBuilder"
)

:: 集成 Windows 10 v1703 默认 Metro 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "15063" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用菜单
	echo.===============================================================================
	echo.  [A]  3D Builder                   ^|  [S]  Solitaire Collection
	echo.  [B]  闹钟和时钟                   ^|  [T]  便笺
	echo.  [C]  计算器                       ^|  [U]  应用商店
	echo.  [D]  日历和邮件                   ^|  [V]  应用商店购买应用
	echo.  [E]  相机                         ^|  [W]  使用技巧
	echo.  [F]  桌面应用安装程序             ^|  [X]  View 3D 预览版
	echo.  [G]  反馈中心                     ^|  [Y]  录音机
	echo.  [H]  获取 Office 应用             ^|  [Z]  电子钱包
	echo.  [I]  Groove 音乐                  ^|  [1]  天气
	echo.  [J]  地图                         ^|  [2]  Xbox 应用
	echo.  [K]  消息                         ^|  [3]  Xbox Game Overlay
	echo.  [L]  电影和电视                   ^|  [4]  Xbox Identity Provider
	echo.  [M]  Office OneNote               ^|  [5]  Xbox SpeechToText Overlay
	echo.  [N]  付费 Wi-Fi 和蜂窝数据        ^|
	echo.  [O]  画图 3D                      ^|
	echo.  [P]  人脉                         ^|
	echo.  [Q]  照片                         ^|  [6]  所有应用
	echo.  [R]  Skype 预览版应用             ^|  [7]  返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567 /N /M "请输入你的选项 ："
	if errorlevel 33 goto :IntFeatures
	if errorlevel 32 set "MetroApp=AllApps"
	if errorlevel 31 set "MetroApp=XboxSpeechToTextOverlay"
	if errorlevel 30 set "MetroApp=XboxIdentityProvider"
	if errorlevel 29 set "MetroApp=XboxGameOverlay"
	if errorlevel 28 set "MetroApp=XboxApp"
	if errorlevel 27 set "MetroApp=BingWeather"
	if errorlevel 26 set "MetroApp=Wallet"
	if errorlevel 25 set "MetroApp=SoundRecorder"
	if errorlevel 24 set "MetroApp=ThreeDViewer"
	if errorlevel 23 set "MetroApp=Getstarted"
	if errorlevel 22 set "MetroApp=StorePurchaseApp"
	if errorlevel 21 set "MetroApp=Store"
	if errorlevel 20 set "MetroApp=StickyNotes"
	if errorlevel 19 set "MetroApp=SolitaireCollection"
	if errorlevel 18 set "MetroApp=SkypeApp"
	if errorlevel 17 set "MetroApp=Photos"
	if errorlevel 16 set "MetroApp=People"
	if errorlevel 15 set "MetroApp=Paint3D"
	if errorlevel 14 set "MetroApp=OneConnect"
	if errorlevel 13 set "MetroApp=OfficeOneNote"
	if errorlevel 12 set "MetroApp=ZuneVideo"
	if errorlevel 11 set "MetroApp=Messaging"
	if errorlevel 10 set "MetroApp=Maps"
	if errorlevel 9  set "MetroApp=ZuneMusic"
	if errorlevel 8  set "MetroApp=OfficeHub"
	if errorlevel 7  set "MetroApp=FeedbackHub"
	if errorlevel 6  set "MetroApp=DesktopAppInstaller"	
	if errorlevel 5  set "MetroApp=Camera"
	if errorlevel 4  set "MetroApp=CommunicationsApps"
	if errorlevel 3  set "MetroApp=Calculator"
	if errorlevel 2  set "MetroApp=Alarms"
	if errorlevel 1  set "MetroApp=ThreeDBuilder"
)

:: 集成 Windows 10 v1709 默认 Metro 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "16299" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用菜单
	echo.===============================================================================
	echo.  [A]  3D Builder                   ^|  [S]  Solitaire Collection
	echo.  [B]  闹钟和时钟                   ^|  [T]  便笺
	echo.  [C]  计算器                       ^|  [U]  应用商店
	echo.  [D]  日历和邮件                   ^|  [V]  应用商店购买应用
	echo.  [E]  相机                         ^|  [W]  使用技巧
	echo.  [F]  桌面应用安装程序             ^|  [X]  View 3D 预览版
	echo.  [G]  反馈中心                     ^|  [Y]  录音机
	echo.  [H]  获取 Office 应用             ^|  [Z]  电子钱包
	echo.  [I]  Groove 音乐                  ^|  [1]  天气
	echo.  [J]  地图                         ^|  [2]  Xbox 应用
	echo.  [K]  消息                         ^|  [3]  Xbox Game Overlay
	echo.  [L]  电影和电视                   ^|  [4]  Xbox Identity Provider
	echo.  [M]  Office OneNote               ^|  [5]  Xbox SpeechToText Overlay
	echo.  [N]  付费 Wi-Fi 和蜂窝数据        ^|
	echo.  [O]  画图 3D                      ^|
	echo.  [P]  人脉                         ^|
	echo.  [Q]  照片                         ^|  [6]  所有应用
	echo.  [R]  Skype 预览版应用             ^|  [7]  返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567 /N /M "请输入你的选项 ："
	if errorlevel 33 goto :IntFeatures
	if errorlevel 32 set "MetroApp=AllApps"
	if errorlevel 31 set "MetroApp=XboxSpeechToTextOverlay"
	if errorlevel 30 set "MetroApp=XboxIdentityProvider"
	if errorlevel 29 set "MetroApp=XboxGameOverlay"
	if errorlevel 28 set "MetroApp=XboxApp"
	if errorlevel 27 set "MetroApp=BingWeather"
	if errorlevel 26 set "MetroApp=Wallet"
	if errorlevel 25 set "MetroApp=SoundRecorder"
	if errorlevel 24 set "MetroApp=ThreeDViewer"
	if errorlevel 23 set "MetroApp=Getstarted"
	if errorlevel 22 set "MetroApp=StorePurchaseApp"
	if errorlevel 21 set "MetroApp=Store"
	if errorlevel 20 set "MetroApp=StickyNotes"
	if errorlevel 19 set "MetroApp=SolitaireCollection"
	if errorlevel 18 set "MetroApp=SkypeApp"
	if errorlevel 17 set "MetroApp=Photos"
	if errorlevel 16 set "MetroApp=People"
	if errorlevel 15 set "MetroApp=Paint3D"
	if errorlevel 14 set "MetroApp=OneConnect"
	if errorlevel 13 set "MetroApp=OfficeOneNote"
	if errorlevel 12 set "MetroApp=ZuneVideo"
	if errorlevel 11 set "MetroApp=Messaging"
	if errorlevel 10 set "MetroApp=Maps"
	if errorlevel 9  set "MetroApp=ZuneMusic"
	if errorlevel 8  set "MetroApp=OfficeHub"
	if errorlevel 7  set "MetroApp=FeedbackHub"
	if errorlevel 6  set "MetroApp=DesktopAppInstaller"	
	if errorlevel 5  set "MetroApp=Camera"
	if errorlevel 4  set "MetroApp=CommunicationsApps"
	if errorlevel 3  set "MetroApp=Calculator"
	if errorlevel 2  set "MetroApp=Alarms"
	if errorlevel 1  set "MetroApp=ThreeDBuilder"
)

:: 集成 Windows 10 v1809/v1903/v1909 默认 Metro 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x86" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用菜单
	echo.===============================================================================
	echo.
	echo.  [A]  3DViewer                 -  混合现实查看器应用
	echo.  [B]  Alarms                   -  闹钟和时钟应用
	echo.  [C]  BingWeather              -  天气应用
	echo.  [D]  Calculator               -  计算器应用
	echo.  [E]  Camera                   -  相机应用
	echo.  [F]  CommunicationsApps       -  Windows 日历和邮件应用
	echo.  [G]  DesktopAppInstaller      -  桌面应用安装程序
	echo.  [H]  Extensions               -  HEIF、HEVC、MPEG2、VP9、Web、Webp 扩展
	echo.  [I]  FeedbackHub              -  反馈中心应用
	echo.  [J]  GetHelp                  -  获取帮助应用
	echo.  [K]  Getstarted               -  使用技巧应用
	echo.  [L]  Maps                     -  地图应用
	echo.  [M]  Messaging                -  消息应用
	echo.  [N]  OfficeHub                -  我的 Office 应用
	echo.  [O]  OfficeOneNote            -  OneNote 应用
	echo.  [P]  OneConnect               -  移动套餐应用
	echo.  [Q]  Paint3D                  -  画图 3D 应用
	echo.  [R]  People                   -  人脉应用
	echo.  [S]  Photos                   -  照片应用
	echo.  [T]  Print3D                  -  Print 3D 应用
	echo.  [U]  ScreenSketch             -  屏幕和草图应用
	echo.  [V]  SkypeApp                 -  Skype 应用
	echo.  [W]  SolitaireCollection      -  Solitaire Collection 应用
	echo.  [X]  SoundRecorder            -  录音机应用
	echo.  [Y]  StickyNotes              -  便笺应用
	echo.  [Z]  Store                    -  Microsoft Store 应用
	echo.  [1]  WalletService            -  电子钱包服务应用
	echo.  [2]  XboxApp                  -  Microsoft Xbox 应用
	echo.  [3]  YourPhone                -  你的手机应用
	echo.  [4]  ZuneMusic                -  Groove 音乐应用
	echo.  [5]  ZuneVideo                -  电影和电视应用
	echo.
	echo.  [6]  所有 Windows 应用
	echo.  [7]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567 /N /M "请输入你的选项 ："
	if errorlevel 33 goto :IntFeatures
	if errorlevel 32 set "MetroApp=AllApps"
	if errorlevel 31 set "MetroApp=ZuneVideo"
	if errorlevel 30 set "MetroApp=ZuneMusic"
	if errorlevel 29 set "MetroApp=YourPhone"
	if errorlevel 28 set "MetroApp=XboxApp"
	if errorlevel 27 set "MetroApp=WalletService"
	if errorlevel 26 set "MetroApp=Store"
	if errorlevel 25 set "MetroApp=StickyNotes"
	if errorlevel 24 set "MetroApp=SoundRecorder"
	if errorlevel 23 set "MetroApp=SolitaireCollection"
	if errorlevel 22 set "MetroApp=SkypeApp"
	if errorlevel 21 set "MetroApp=ScreenSketch"
	if errorlevel 20 set "MetroApp=Print3D"
	if errorlevel 19 set "MetroApp=Photos"
	if errorlevel 18 set "MetroApp=People"
	if errorlevel 17 set "MetroApp=Paint3D"
	if errorlevel 16 set "MetroApp=OneConnect"
	if errorlevel 15 set "MetroApp=OfficeOneNote"
	if errorlevel 14 set "MetroApp=OfficeHub"
	if errorlevel 13 set "MetroApp=Messaging"
	if errorlevel 12 set "MetroApp=Maps"
	if errorlevel 11 set "MetroApp=Getstarted"
	if errorlevel 10 set "MetroApp=GetHelp"
	if errorlevel 9  set "MetroApp=FeedbackHub"
	if errorlevel 8  set "MetroApp=Extensions"
	if errorlevel 7  set "MetroApp=DesktopAppInstaller"
	if errorlevel 6  set "MetroApp=CommunicationsApps"
	if errorlevel 5  set "MetroApp=Camera"
	if errorlevel 4  set "MetroApp=Calculator"
	if errorlevel 3  set "MetroApp=BingWeather"
	if errorlevel 2  set "MetroApp=Alarms"
	if errorlevel 1  set "MetroApp=ThreeDViewer"
)

:: 集成 Windows 10 v1809/v1903/v1909 默认 Metro 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x64" (
	cls
	echo.===============================================================================
	echo.              MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用菜单
	echo.===============================================================================
	echo.
	echo.  [A]  3DViewer                 -  混合现实查看器应用
	echo.  [B]  Alarms                   -  闹钟和时钟应用
	echo.  [C]  BingWeather              -  天气应用
	echo.  [D]  Calculator               -  计算器应用
	echo.  [E]  Camera                   -  相机应用
	echo.  [F]  CommunicationsApps       -  Windows 日历和邮件应用
	echo.  [G]  DesktopAppInstaller      -  桌面应用安装程序
	echo.  [H]  Extensions               -  HEIF、HEVC、MPEG2、VP9、Web、Webp 扩展
	echo.  [I]  FeedbackHub              -  反馈中心应用
	echo.  [J]  GetHelp                  -  获取帮助应用
	echo.  [K]  Getstarted               -  使用技巧应用
	echo.  [L]  Maps                     -  地图应用
	echo.  [M]  Messaging                -  消息应用
	echo.  [N]  MixedRealityPortal       -  混合现实门户应用
	echo.  [O]  OfficeHub                -  我的 Office 应用
	echo.  [P]  OfficeOneNote            -  OneNote 应用
	echo.  [Q]  OneConnect               -  移动套餐应用
	echo.  [R]  Paint3D                  -  画图 3D 应用
	echo.  [S]  People                   -  人脉应用
	echo.  [T]  Photos                   -  照片应用
	echo.  [U]  Print3D                  -  Print 3D 应用
	echo.  [V]  ScreenSketch             -  屏幕和草图应用
	echo.  [W]  SkypeApp                 -  Skype 应用
	echo.  [X]  SolitaireCollection      -  Solitaire Collection 应用
	echo.  [Y]  SoundRecorder            -  录音机应用
	echo.  [Z]  StickyNotes              -  便笺应用
	echo.  [1]  Store                    -  Microsoft Store 应用
	echo.  [2]  WalletService            -  电子钱包服务应用
	echo.  [3]  XboxApp                  -  Microsoft Xbox 应用
	echo.  [4]  YourPhone                -  你的手机应用
	echo.  [5]  ZuneMusic                -  Groove 音乐应用
	echo.  [6]  ZuneVideo                -  电影和电视应用
	echo.
	echo.  [7]  所有 Windows 应用
	echo.  [8]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678 /N /M "请输入你的选项 ："
	if errorlevel 34 goto :IntFeatures
	if errorlevel 33 set "MetroApp=AllApps"
	if errorlevel 32 set "MetroApp=ZuneVideo"
	if errorlevel 31 set "MetroApp=ZuneMusic"
	if errorlevel 30 set "MetroApp=YourPhone"
	if errorlevel 29 set "MetroApp=XboxApp"
	if errorlevel 28 set "MetroApp=WalletService"
	if errorlevel 27 set "MetroApp=Store"
	if errorlevel 26 set "MetroApp=StickyNotes"
	if errorlevel 25 set "MetroApp=SoundRecorder"
	if errorlevel 24 set "MetroApp=SolitaireCollection"
	if errorlevel 23 set "MetroApp=SkypeApp"
	if errorlevel 22 set "MetroApp=ScreenSketch"
	if errorlevel 21 set "MetroApp=Print3D"
	if errorlevel 20 set "MetroApp=Photos"
	if errorlevel 19 set "MetroApp=People"
	if errorlevel 18 set "MetroApp=Paint3D"
	if errorlevel 17 set "MetroApp=OneConnect"
	if errorlevel 16 set "MetroApp=OfficeOneNote"
	if errorlevel 15 set "MetroApp=OfficeHub"
	if errorlevel 14 set "MetroApp=MixedRealityPortal"
	if errorlevel 13 set "MetroApp=Messaging"
	if errorlevel 12 set "MetroApp=Maps"
	if errorlevel 11 set "MetroApp=Getstarted"
	if errorlevel 10 set "MetroApp=GetHelp"
	if errorlevel 9  set "MetroApp=FeedbackHub"
	if errorlevel 8  set "MetroApp=Extensions"
	if errorlevel 7  set "MetroApp=DesktopAppInstaller"
	if errorlevel 6  set "MetroApp=CommunicationsApps"
	if errorlevel 5  set "MetroApp=Camera"
	if errorlevel 4  set "MetroApp=Calculator"
	if errorlevel 3  set "MetroApp=BingWeather"
	if errorlevel 2  set "MetroApp=Alarms"
	if errorlevel 1  set "MetroApp=ThreeDViewer"
)

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置默认 Metro 应用包路径
if "%SelectedSourceOS%" equ "w81" set "Apps=%Apps%\%SelectedSourceOS%"
if "%SelectedSourceOS%" equ "w10" set "Apps=%Apps%\%SelectedSourceOS%\10.0.%ImageBuild%"

:: 检查 Microsoft 默认 Metro 应用文件夹是否是空的
if not exist "%Apps%\*.appxbundle" (
	echo.Microsoft 默认 Metro 应用 Appxbundle 文件缺失……
	echo.
	if "%SelectedSourceOS%" equ "w81" echo.请将缺失的文件复制到 ^<Packs\Apps\%SelectedSourceOS%^> 文件夹……
	if "%SelectedSourceOS%" equ "w10" echo.请将缺失的文件复制到 ^<Packs\Apps\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	echo.
	goto :Stop
)

if not exist "%Apps%\*.appx" (
	echo.Microsoft 默认 Metro 应用 Appx 文件缺失……
	echo.
	if "%SelectedSourceOS%" equ "w81" echo.请将缺失的文件复制到 ^<Packs\Apps\%SelectedSourceOS%^> 文件夹……
	if "%SelectedSourceOS%" equ "w10" echo.请将缺失的文件复制到 ^<Packs\Apps\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	echo.
	goto :Stop
)

if not exist "%Apps%\*.xml" (
	echo.Microsoft 默认 Metro 应用许可 XML 文件缺失……
	echo.
	if "%SelectedSourceOS%" equ "w81" echo.请将缺失的文件复制到 ^<Packs\Apps\%SelectedSourceOS%^> 文件夹……
	if "%SelectedSourceOS%" equ "w10" echo.请将缺失的文件复制到 ^<Packs\Apps\%SelectedSourceOS%\10.0.%ImageBuild%^> 文件夹……
	echo.
	goto :Stop
)

:: 获取 Microsoft 默认 Metro 应用文件的完整路径
cd /d "%Apps%\"

for /f %%i IN ('"dir /b Microsoft.Advertising.Xaml*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "AdvertisingXaml_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.Advertising.Xaml*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "AdvertisingXaml_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.Advertising.Xaml*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "AdvertisingXaml_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.Advertising.Xaml*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "AdvertisingXaml_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b *PlayReadyClient*arm.appx" 2^>nul') do set "MediaPlayReadyClient22_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b *PlayReadyClient*x86.appx" 2^>nul') do set "MediaPlayReadyClient22_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b *PlayReadyClient*x64.appx" 2^>nul') do set "MediaPlayReadyClient22_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.3*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework13_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.3*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework13_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.3*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework13_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.6*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework16_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.6*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework16_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.6*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework16_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.7*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework17_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.7*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework17_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.1.7*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework17_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.2.1*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework21_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.2.1*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework21_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.2.1*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework21_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.2.2*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework22_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.2.2*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework22_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.2.2*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework22_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Framework.2.2*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeFramework22_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.3*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime13_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.3*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime13_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.3*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime13_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.4*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime14_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.4*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime14_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.4*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime14_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.6*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime16_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.6*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime16_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.6*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime16_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.7*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime17_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.7*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime17_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.1.7*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime17_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.2.1*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime21_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.2.1*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime21_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.2.1*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime21_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.2.1*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime21_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.2.2*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime22_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.2.2*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime22_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.2.2*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime22_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.NET.Native.Runtime.2.2*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "NETNativeRuntime22_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.Services.Store.Engagement*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "ServicesStoreEngagement_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.Services.Store.Engagement*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "ServicesStoreEngagement_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.Services.Store.Engagement*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "ServicesStoreEngagement_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.Services.Store.Engagement*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "ServicesStoreEngagement_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.UI.Xaml.2.0*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "UIXaml20_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.UI.Xaml.2.0*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "UIXaml20_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.UI.Xaml.2.0*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "UIXaml20_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.UI.Xaml.2.0*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "UIXaml20_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.UI.Xaml.2.1*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "UIXaml21_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.UI.Xaml.2.1*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "UIXaml21_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.UI.Xaml.2.1*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "UIXaml21_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.UI.Xaml.2.1*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "UIXaml21_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.120.00*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibs12_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.120.00*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibs12_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.120.00*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibs12_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.140.00*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibs14_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.140.00*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibs14_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.140.00*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibs14_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.140.00*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibs14_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.140.00.UWPDesktop*_arm__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibsUWPDesktop14_arm_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.140.00.UWPDesktop*_arm64__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibsUWPDesktop14_arm64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.140.00.UWPDesktop*_x86__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibsUWPDesktop14_x86_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.VCLibs.140.00.UWPDesktop*_x64__8wekyb3d8bbwe.Appx" 2^>nul') do set "VCLibsUWPDesktop14_x64_Appx=/DependencyPackagePath:%Apps%\%%i"
for /f %%i IN ('"dir /b Microsoft.WinJS*.appx" 2^>nul') do set "WinJS20_Appx=/DependencyPackagePath:%Apps%\%%i"

set AdvertisingXaml=
set DependencyPackages=
set NETNativeFramework13=
set NETNativeFramework16=
set NETNativeFramework17=
set NETNativeFramework21=
set NETNativeFramework22=
set NETNativeRuntime13=
set NETNativeRuntime14=
set NETNativeRuntime16=
set NETNativeRuntime17=
set NETNativeRuntime21=
set NETNativeRuntime22=
set ServicesStoreEngagement=
set UIXaml20=
set UIXaml21=
set VCLibs14=
set VCLibsUWPDesktop14=

if "%ImageArchitecture%" equ "x86" (
	set "AdvertisingXaml=%AdvertisingXaml_x86_Appx%
	set "NETNativeFramework13=%NETNativeFramework13_x86_Appx%
	set "NETNativeFramework16=%NETNativeFramework16_x86_Appx%
	set "NETNativeFramework17=%NETNativeFramework17_x86_Appx%
	set "NETNativeFramework21=%NETNativeFramework21_x86_Appx%
	set "NETNativeFramework22=%NETNativeFramework22_x86_Appx%
	set "NETNativeRuntime13=%NETNativeRuntime13_x86_Appx%
	set "NETNativeRuntime14=%NETNativeRuntime14_x86_Appx%
	set "NETNativeRuntime16=%NETNativeRuntime16_x86_Appx%
	set "NETNativeRuntime17=%NETNativeRuntime17_x86_Appx%
	set "NETNativeRuntime21=%NETNativeRuntime21_x86_Appx%
	set "NETNativeRuntime22=%NETNativeRuntime22_x86_Appx%
	set "ServicesStoreEngagement=%ServicesStoreEngagement_x86_Appx%
	set "UIXaml20=%UIXaml20_x86_Appx%
	set "UIXaml21=%UIXaml21_x86_Appx%
	set "VCLibs14=%VCLibs14_x86_Appx%
	set "VCLibsUWPDesktop14=%VCLibsUWPDesktop14_x86_Appx%
)

if "%ImageArchitecture%" equ "x64" (
	set "AdvertisingXaml=%AdvertisingXaml_x86_Appx% %AdvertisingXaml_x64_Appx%
	set "NETNativeFramework13=%NETNativeFramework13_x86_Appx% %NETNativeFramework13_x64_Appx%
	set "NETNativeFramework16=%NETNativeFramework16_x86_Appx% %NETNativeFramework16_x64_Appx%
	set "NETNativeFramework17=%NETNativeFramework17_x86_Appx% %NETNativeFramework17_x64_Appx%
	set "NETNativeFramework21=%NETNativeFramework21_x86_Appx% %NETNativeFramework21_x64_Appx%
	set "NETNativeFramework22=%NETNativeFramework22_x86_Appx% %NETNativeFramework22_x64_Appx%
	set "NETNativeRuntime13=%NETNativeRuntime13_x86_Appx% %NETNativeRuntime13_x64_Appx%
	set "NETNativeRuntime14=%NETNativeRuntime14_x86_Appx% %NETNativeRuntime14_x64_Appx%
	set "NETNativeRuntime16=%NETNativeRuntime16_x86_Appx% %NETNativeRuntime16_x64_Appx%
	set "NETNativeRuntime17=%NETNativeRuntime17_x86_Appx% %NETNativeRuntime17_x64_Appx%
	set "NETNativeRuntime21=%NETNativeRuntime21_x86_Appx% %NETNativeRuntime21_x64_Appx%
	set "NETNativeRuntime22=%NETNativeRuntime22_x86_Appx% %NETNativeRuntime22_x64_Appx%
	set "ServicesStoreEngagement=%ServicesStoreEngagement_x86_Appx% %ServicesStoreEngagement_x64_Appx%
	set "UIXaml20=%UIXaml20_x86_Appx% %UIXaml20_x64_Appx%
	set "UIXaml21=%UIXaml21_x86_Appx% %UIXaml21_x64_Appx%
	set "VCLibs14=%VCLibs14_x86_Appx% %VCLibs14_x64_Appx%
	set "VCLibsUWPDesktop14=%VCLibsUWPDesktop14_x86_Appx% %VCLibsUWPDesktop14_x64_Appx%
)

if "%ImageArchitecture%" equ "arm64" (
	set "AdvertisingXaml=%AdvertisingXaml_arm_Appx% %AdvertisingXaml_arm64_Appx%
	set "NETNativeFramework13=%NETNativeFramework13_arm_Appx% %NETNativeFramework13_arm64_Appx%
	set "NETNativeFramework16=%NETNativeFramework16_arm_Appx% %NETNativeFramework16_arm64_Appx%
	set "NETNativeFramework17=%NETNativeFramework17_arm_Appx% %NETNativeFramework17_arm64_Appx%
	set "NETNativeFramework21=%NETNativeFramework21_arm_Appx% %NETNativeFramework21_arm64_Appx%
	set "NETNativeFramework22=%NETNativeFramework22_arm_Appx% %NETNativeFramework22_arm64_Appx%
	set "NETNativeRuntime13=%NETNativeRuntime13_arm_Appx% %NETNativeRuntime13_arm64_Appx%
	set "NETNativeRuntime14=%NETNativeRuntime14_arm_Appx% %NETNativeRuntime14_arm64_Appx%
	set "NETNativeRuntime16=%NETNativeRuntime16_arm_Appx% %NETNativeRuntime16_arm64_Appx%
	set "NETNativeRuntime17=%NETNativeRuntime17_arm_Appx% %NETNativeRuntime17_arm64_Appx%
	set "NETNativeRuntime21=%NETNativeRuntime21_arm_Appx% %NETNativeRuntime21_arm64_Appx%
	set "NETNativeRuntime22=%NETNativeRuntime22_arm_Appx% %NETNativeRuntime22_arm64_Appx%
	set "ServicesStoreEngagement=%ServicesStoreEngagement_arm_Appx% %ServicesStoreEngagement_arm64_Appx%
	set "UIXaml20=%UIXaml20_arm_Appx% %UIXaml20_arm64_Appx%
	set "UIXaml21=%UIXaml21_arm_Appx% %UIXaml21_arm64_Appx%
	set "VCLibs14=%VCLibs14_x86_Appx% %VCLibs14_arm_Appx% %VCLibs14_arm64_Appx%
	set "VCLibsUWPDesktop14=%VCLibsUWPDesktop14_x86_Appx% %VCLibsUWPDesktop14_arm_Appx% %VCLibsUWPDesktop14_arm64_Appx%
)

if "%SelectedSourceOS%" equ "w81" set "DependencyPackages=%VCLibs12_x86_Appx% %VCLibs12_x64_Appx% %VCLibs12_arm_Appx% %WinJS20Appx% %MediaPlayReadyClient22_x86_Appx% %MediaPlayReadyClient22_x64_Appx% %MediaPlayReadyClient22_arm_Appx%"

if "%SelectedSourceOS%" equ "w10" (
	if "%ImageBuild%" equ "16299" set "DependencyPackages=%AdvertisingXaml% %NETNativeFramework13% %NETNativeFramework16% %NETNativeFramework17% %NETNativeFramework21% %NETNativeFramework22% %NETNativeRuntime13% %NETNativeRuntime14% %NETNativeRuntime16% %NETNativeRuntime17% %NETNativeRuntime21% %NETNativeRuntime22% %ServicesStoreEngagement% %UIXaml20% %UIXaml21% %VCLibs14% %VCLibsUWPDesktop14%"
	if "%ImageBuild%" equ "17134" set "DependencyPackages=%AdvertisingXaml% %NETNativeFramework13% %NETNativeFramework16% %NETNativeFramework17% %NETNativeFramework21% %NETNativeFramework22% %NETNativeRuntime13% %NETNativeRuntime14% %NETNativeRuntime16% %NETNativeRuntime17% %NETNativeRuntime21% %NETNativeRuntime22% %ServicesStoreEngagement% %UIXaml20% %UIXaml21% %VCLibs14% %VCLibsUWPDesktop14%"
	if "%ImageBuild%" equ "17763" set "DependencyPackages=%AdvertisingXaml% %NETNativeFramework16% %NETNativeFramework17% %NETNativeFramework21% %NETNativeFramework22% %NETNativeRuntime16% %NETNativeRuntime17% %NETNativeRuntime21% %NETNativeRuntime22% %ServicesStoreEngagement% %UIXaml20% %UIXaml21% %VCLibs14% %VCLibsUWPDesktop14%"
	if "%ImageBuild%" equ "18362" set "DependencyPackages=%AdvertisingXaml% %NETNativeFramework17% %NETNativeFramework22% %NETNativeRuntime17% %NETNativeRuntime22% %ServicesStoreEngagement% %UIXaml21% %VCLibs14% %VCLibsUWPDesktop14%"
)

for /f %%i IN ('"dir /b *Alarms*.appxbundle" 2^>nul') do if exist %%i set "Alarms_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *AppConnector*.appxbundle" 2^>nul') do if exist %%i set "AppConnector_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingFinance*.appxbundle" 2^>nul') do if exist %%i set "BingFinance_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingFoodAndDrink*.appxbundle" 2^>nul') do if exist %%i set "BingFoodDrink_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingHealthAndFitness*.appxbundle" 2^>nul') do if exist %%i set "BingHealthFitness_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingMaps*.appxbundle" 2^>nul') do if exist %%i set "BingMaps_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingNews*.appxbundle" 2^>nul') do if exist %%i set "BingNews_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingSports*.appxbundle" 2^>nul') do if exist %%i set "BingSports_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingTravel*.appxbundle" 2^>nul') do if exist %%i set "BingTravel_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingWeather*.appxbundle" 2^>nul') do if exist %%i set "BingWeather_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Calculator*.appxbundle" 2^>nul') do if exist %%i set "Calculator_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Camera*.appxbundle" 2^>nul') do if exist %%i set "Camera_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *CommunicationsApps*.appxbundle" 2^>nul') do if exist %%i set "CommunicationsApps_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *DesktopAppInstaller*.appxbundle" 2^>nul') do if exist %%i set "DesktopAppInstaller_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *FeedbackHub*.appxbundle" 2^>nul') do if exist %%i set "FeedbackHub_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *GetHelp*.appxbundle" 2^>nul') do if exist %%i set "GetHelp_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Getstarted*.appxbundle" 2^>nul') do if exist %%i set "Getstarted_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEIFImageExtension*arm*.appx" 2^>nul') do if exist %%i set "HEIFImageExtension_arm_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEIFImageExtension*x86*.appx" 2^>nul') do if exist %%i set "HEIFImageExtension_x86_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEIFImageExtension*x64*.appx" 2^>nul') do if exist %%i set "HEIFImageExtension_x64_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEVCVideoExtension*arm*.appx" 2^>nul') do if exist %%i set "HEVCVideoExtension_arm_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEVCVideoExtension*x86*.appx" 2^>nul') do if exist %%i set "HEVCVideoExtension_x86_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEVCVideoExtension*x64*.appx" 2^>nul') do if exist %%i set "HEVCVideoExtension_x64_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *HelpAndTips*.appxbundle" 2^>nul') do if exist %%i set "HelpAndTips_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Maps*.appxbundle" 2^>nul') do if exist %%i set "Maps_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Messaging*.appxbundle" 2^>nul') do if exist %%i set "Messaging_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *MixedReality.Portal*.appxbundle" 2^>nul') do if exist %%i set "MixedRealityPortal_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *MPEG2VideoExtension*arm*.appx" 2^>nul') do if exist %%i set "MPEG2VideoExtension_arm_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *MPEG2VideoExtension*x86*.appx" 2^>nul') do if exist %%i set "MPEG2VideoExtension_x86_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *MPEG2VideoExtension*x64*.appx" 2^>nul') do if exist %%i set "MPEG2VideoExtension_x64_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *OfficeHub*.appxbundle" 2^>nul') do if exist %%i set "OfficeHub_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *OneNote*.appxbundle" 2^>nul') do if exist %%i set "OfficeOneNote_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Sway*.appxbundle" 2^>nul') do if exist %%i set "OfficeSway_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *OneConnect*.appxbundle" 2^>nul') do if exist %%i set "OneConnect_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Paint*.appxbundle" 2^>nul') do if exist %%i set "Paint3D_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *People*.appxbundle" 2^>nul') do if exist %%i set "People_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *CommsPhone*.appxbundle" 2^>nul') do if exist %%i set "Phone_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *WindowsPhone*.appxbundle" 2^>nul') do if exist %%i set "PhoneCompanion_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Photos*.appxbundle" 2^>nul') do if exist %%i set "Photos_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Print3D*.appxbundle" 2^>nul') do if exist %%i set "Print3D_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Reader*.appxbundle" 2^>nul') do if exist %%i set "Reader_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *ReadingList*.appxbundle" 2^>nul') do if exist %%i set "ReadingList_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Scan*.appxbundle" 2^>nul') do if exist %%i set "Scan_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *ScreenSketch*.appxbundle" 2^>nul') do if exist %%i set "ScreenSketch_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Skype*.appxbundle" 2^>nul') do if exist %%i set "SkypeApp_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *SolitaireCollection*.appxbundle" 2^>nul') do if exist %%i set "SolitaireCollection_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *SoundRecorder*.appxbundle" 2^>nul') do if exist %%i set "SoundRecorder_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *StickyNotes*.appxbundle" 2^>nul') do if exist %%i set "StickyNotes_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Store*.appxbundle" 2^>nul') do if exist %%i set "Store_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *StorePurchaseApp*.appxbundle" 2^>nul') do if exist %%i set "StorePurchaseApp_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *3DBuilder*.appxbundle" 2^>nul') do if exist %%i set "ThreeDBuilder_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *3DView*.appxbundle" 2^>nul') do if exist %%i set "ThreeDViewer_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *VP9VideoExtensions*arm*.appx" 2^>nul') do if exist %%i set "VP9VideoExtensions_arm_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *VP9VideoExtensions*x86*.appx" 2^>nul') do if exist %%i set "VP9VideoExtensions_x86_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *VP9VideoExtensions*x64*.appx" 2^>nul') do if exist %%i set "VP9VideoExtensions_x64_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Wallet*.appxbundle" 2^>nul') do if exist %%i set "Wallet_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *WebMediaExtensions*.appxbundle" 2^>nul') do if exist %%i set "WebMediaExtensions_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *WebpImageExtension*arm*.appx" 2^>nul') do if exist %%i set "WebpImageExtension_arm_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *WebpImageExtension*x86*.appx" 2^>nul') do if exist %%i set "WebpImageExtension_x86_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *WebpImageExtension*x64*.appx" 2^>nul') do if exist %%i set "WebpImageExtension_x64_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *ConnectivityStore*.appxbundle" 2^>nul') do if exist %%i set "WiFi_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxApp*.appxbundle" 2^>nul') do if exist %%i set "XboxApp_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxGameOverlay*.appxbundle" 2^>nul') do if exist %%i set "XboxGameOverlay_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxGamingOverlay*.appxbundle" 2^>nul') do if exist %%i set "XboxGamingOverlay_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxIdentityProvider*.appxbundle" 2^>nul') do if exist %%i set "XboxIdentityProvider_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxLIVEGames*.appxbundle" 2^>nul') do if exist %%i set "XboxLiveGames_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxSpeechToTextOverlay*.appxbundle" 2^>nul') do if exist %%i set "XboxSpeechToTextOverlay_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Xbox.TCUI*.appxbundle" 2^>nul') do if exist %%i set "XboxTCUI_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *Microsoft.YourPhone*.appxbundle" 2^>nul') do if exist %%i set "YourPhone_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *ZuneMusic*.appxbundle" 2^>nul') do if exist %%i set "ZuneMusic_Appx=%Apps%\%%i"
for /f %%i IN ('"dir /b *ZuneVideo*.appxbundle" 2^>nul') do if exist %%i set "ZuneVideo_Appx=%Apps%\%%i"

for /f %%i IN ('"dir /b *Alarms*.xml" 2^>nul') do if exist %%i set "Alarms_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *AppConnector*.xml" 2^>nul') do if exist %%i set "AppConnector_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingFinance*.xml" 2^>nul') do if exist %%i set "BingFinance_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingFoodAndDrink*.xml" 2^>nul') do if exist %%i set "BingFoodDrink_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingHealthAndFitness*.xml" 2^>nul') do if exist %%i set "BingHealthFitness_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingMaps*.xml" 2^>nul') do if exist %%i set "BingMaps_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingNews*.xml" 2^>nul') do if exist %%i set "BingNews_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingSports*.xml" 2^>nul') do if exist %%i set "BingSports_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingTravel*.xml" 2^>nul') do if exist %%i set "BingTravel_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *BingWeather*.xml" 2^>nul') do if exist %%i set "BingWeather_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Calculator*.xml" 2^>nul') do if exist %%i set "Calculator_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Camera*.xml" 2^>nul') do if exist %%i set "Camera_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *CommunicationsApps*.xml" 2^>nul') do if exist %%i set "CommunicationsApps_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *DesktopAppInstaller*.xml" 2^>nul') do if exist %%i set "DesktopAppInstaller_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *FeedbackHub*.xml" 2^>nul') do if exist %%i set "FeedbackHub_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *GetHelp*.xml" 2^>nul') do if exist %%i set "GetHelp_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Getstarted*.xml" 2^>nul') do if exist %%i set "Getstarted_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEIFImageExtension*arm*.xml" 2^>nul') do if exist %%i set "HEIFImageExtension_arm_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEIFImageExtension*x86*.xml" 2^>nul') do if exist %%i set "HEIFImageExtension_x86_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEIFImageExtension*x64*.xml" 2^>nul') do if exist %%i set "HEIFImageExtension_x64_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEVCVideoExtension*arm*.xml" 2^>nul') do if exist %%i set "HEVCVideoExtension_arm_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEVCVideoExtension*x86*.xml" 2^>nul') do if exist %%i set "HEVCVideoExtension_x86_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *HEVCVideoExtension*x64*.xml" 2^>nul') do if exist %%i set "HEVCVideoExtension_x64_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *HelpAndTips*.xml" 2^>nul') do if exist %%i set "HelpAndTips_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Maps*.xml" 2^>nul') do if exist %%i set "Maps_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Messaging*.xml" 2^>nul') do if exist %%i set "Messaging_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *MixedReality.Portal*.xml" 2^>nul') do if exist %%i set "MixedRealityPortal_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *MPEG2VideoExtension*arm*.xml" 2^>nul') do if exist %%i set "MPEG2VideoExtension_arm_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *MPEG2VideoExtension*x86*.xml" 2^>nul') do if exist %%i set "MPEG2VideoExtension_x86_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *MPEG2VideoExtension*x64*.xml" 2^>nul') do if exist %%i set "MPEG2VideoExtension_x64_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *OfficeHub*.xml" 2^>nul') do if exist %%i set "OfficeHub_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *OneNote*.xml" 2^>nul') do if exist %%i set "OfficeOneNote_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Sway*.xml" 2^>nul') do if exist %%i set "OfficeSway_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *OneConnect*.xml" 2^>nul') do if exist %%i set "OneConnect_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Paint*.xml" 2^>nul') do if exist %%i set "Paint3D_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *People*.xml" 2^>nul') do if exist %%i set "People_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *CommsPhone*.xml" 2^>nul') do if exist %%i set "Phone_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *WindowsPhone*.xml" 2^>nul') do if exist %%i set "PhoneCompanion_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Photos*.xml" 2^>nul') do if exist %%i set "Photos_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Print3D*.xml" 2^>nul') do if exist %%i set "Print3D_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Reader*.xml" 2^>nul') do if exist %%i set "Reader_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *ReadingList*.xml" 2^>nul') do if exist %%i set "ReadingList_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Scan*.xml" 2^>nul') do if exist %%i set "Scan_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *ScreenSketch*.xml" 2^>nul') do if exist %%i set "ScreenSketch_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Skype*.xml" 2^>nul') do if exist %%i set "SkypeApp_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *SolitaireCollection*.xml" 2^>nul') do if exist %%i set "SolitaireCollection_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *SoundRecorder*.xml" 2^>nul') do if exist %%i set "SoundRecorder_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *StickyNotes*.xml" 2^>nul') do if exist %%i set "StickyNotes_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Store*.xml" 2^>nul') do if exist %%i set "Store_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *StorePurchaseApp*.xml" 2^>nul') do if exist %%i set "StorePurchaseApp_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *3DBuilder*.xml" 2^>nul') do if exist %%i set "ThreeDBuilder_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *3DView*.xml" 2^>nul') do if exist %%i set "ThreeDViewer_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *VP9VideoExtensions*arm*.xml" 2^>nul') do if exist %%i set "VP9VideoExtensions_arm_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *VP9VideoExtensions*x86*.xml" 2^>nul') do if exist %%i set "VP9VideoExtensions_x86_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *VP9VideoExtensions*x64*.xml" 2^>nul') do if exist %%i set "VP9VideoExtensions_x64_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Wallet*.xml" 2^>nul') do if exist %%i set "Wallet_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *WebMediaExtensions*.xml" 2^>nul') do if exist %%i set "WebMediaExtensions_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *WebpImageExtension*arm*.xml" 2^>nul') do if exist %%i set "WebpImageExtension_arm_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *WebpImageExtension*x86*.xml" 2^>nul') do if exist %%i set "WebpImageExtension_x86_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *WebpImageExtension*x64*.xml" 2^>nul') do if exist %%i set "WebpImageExtension_x64_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *ConnectivityStore*.xml" 2^>nul') do if exist %%i set "WiFi_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxApp*.xml" 2^>nul') do if exist %%i set "XboxApp_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxGameOverlay*.xml" 2^>nul') do if exist %%i set "XboxGameOverlay_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxGamingOverlay*.xml" 2^>nul') do if exist %%i set "XboxGamingOverlay_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxIdentityProvider*.xml" 2^>nul') do if exist %%i set "XboxIdentityProvider_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxLIVEGames*.xml" 2^>nul') do if exist %%i set "XboxLiveGames_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *XboxSpeechToTextOverlay*.xml" 2^>nul') do if exist %%i set "XboxSpeechToTextOverlay_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Xbox.TCUI*.xml" 2^>nul') do if exist %%i set "XboxTCUI_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *Microsoft.YourPhone*.xml" 2^>nul') do if exist %%i set "YourPhone_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *ZuneMusic*.xml" 2^>nul') do if exist %%i set "ZuneMusic_License=%Apps%\%%i"
for /f %%i IN ('"dir /b *ZuneVideo*.xml" 2^>nul') do if exist %%i set "ZuneVideo_License=%Apps%\%%i"

cd /d "%ROOT%\"

cls
echo.===============================================================================
echo. 	             MSMG 工具箱 - 集成 Microsoft 默认 Metro 应用
echo.===============================================================================
echo.
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft 默认 Metro 应用#####################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft 默认 Metro 应用#########################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
	
		:: 集成 Windows 8.1 默认 Metro 应用到安装映像文件
		if "%SelectedSourceOS%" equ "w81" (	
			if "%MetroApp%" equ "Alarms" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "闹钟", %Alarms_Appx%, %Alarms_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Calculator" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "计算器", %Calculator_Appx%, %Calculator_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "CommunicationsApps" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "日历、邮件和人脉", %CommunicationsApps_Appx%, %CommunicationsApps_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingFinance" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 财经", %BingFinance_Appx%, %BingFinance_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingFoodDrink" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 美食", %BingFoodDrink_Appx%, %BingFoodDrink_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingHealthFitness" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 健康", %BingHealthFitness_Appx%, %BingHealthFitness_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingMaps" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 地图", %BingMaps_Appx%, %BingMaps_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingNews" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 资讯", %BingNews_Appx%, %BingNews_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingSports" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 体育", %BingSports_Appx%, %BingSports_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingTravel" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 旅游", %BingTravel_Appx%, %BingTravel_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingWeather" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "HelpAndTips" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "帮助和提示", %HelpAndTips_Appx%, %HelpAndTips_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "OfficeOneNote" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Office OneNote", %OfficeOneNote_Appx%, %OfficeOneNote_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Reader" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "阅读器", %Reader_Appx%, %Reader_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ReadingList" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "阅读列表", %ReadingList_Appx%, %ReadingList_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Scan" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "扫描", %Scan_Appx%, %Scan_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "SkypeApp" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Skype 应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "SoundRecorder" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "录音机", %SoundRecorder_Appx%, %SoundRecorder_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "XboxLiveGames" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Live 游戏", %XboxLiveGames_Appx%, %XboxLiveGames_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ZuneMusic" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Zune 音乐", %ZuneMusic_Appx%, %ZuneMusic_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ZuneVideo" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Zune 视频", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
		)

		:: 集成 Windows 10 默认 Metro 应用到安装映像
		if "%SelectedSourceOS%" equ "w10" (
			if "%MetroApp%" equ "Alarms" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "闹钟和时钟", %Alarms_Appx%, %Alarms_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "AppConnector" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "应用连接器", %AppConnector_Appx%, %AppConnector_License%, ""
			if "%MetroApp%" equ "BingFinance" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 财经", %BingFinance_Appx%, %BingFinance_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingNews" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 资讯", %BingNews_Appx%, %BingNews_License%, %BingNews_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingSports" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 体育", %BingSports_Appx%, %BingSports_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingWeather" if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "BingWeather" if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Calculator" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "计算器", %Calculator_Appx%, %Calculator_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Camera" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "相机", %Camera_Appx%, %Camera_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "CommunicationsApps" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "日历和邮件", %CommunicationsApps_Appx%, %CommunicationsApps_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "DesktopAppInstaller" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "桌面应用安装程序", %DesktopAppInstaller_Appx%, %DesktopAppInstaller_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Extensions" (
				if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x86" (
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEIF 图像扩展", %HEIFImageExtension_x86_Appx%, %HEIFImageExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEVC 视频扩展", %HEVCVideoExtension_x86_Appx%, %HEVCVideoExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "MPEG2 视频扩展", %MPEG2VideoExtension_x86_Appx%, %MPEG2VideoExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "VP9 视频扩展", %VP9VideoExtensions_x86_Appx%, %VP9VideoExtensions_x86_License%, "%DependencyPackages%"
				)
				if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x64" (
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEIF 图像扩展 x86", %HEIFImageExtension_x86_Appx%, %HEIFImageExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEIF 图像扩展 x64", %HEIFImageExtension_x64_Appx%, %HEIFImageExtension_x64_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEVC 视频扩展 x86", %HEVCVideoExtension_x86_Appx%, %HEVCVideoExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEVC 视频扩展 x64", %HEVCVideoExtension_x64_Appx%, %HEVCVideoExtension_x64_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "MPEG2 视频扩展 x86", %MPEG2VideoExtension_x86_Appx%, %MPEG2VideoExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "MPEG2 视频扩展 x64", %MPEG2VideoExtension_x64_Appx%, %MPEG2VideoExtension_x64_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "VP9 视频扩展 x86", %VP9VideoExtensions_x86_Appx%, %VP9VideoExtensions_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "VP9 视频扩展 x64", %VP9VideoExtensions_x64_Appx%, %VP9VideoExtensions_x64_License%, "%DependencyPackages%"
				)
				if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "arm64" (
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEIF 图像扩展", %HEIFImageExtension_arm_Appx%, %HEIFImageExtension_arm_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEVC 视频扩展", %HEVCVideoExtension_arm_Appx%, %HEVCVideoExtension_arm_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "MPEG2 视频扩展", %MPEG2VideoExtension_arm_Appx%, %MPEG2VideoExtension_arm_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "VP9 视频扩展", %VP9VideoExtensions_arm_Appx%, %VP9VideoExtensions_arm_License%, "%DependencyPackages%"
				)
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Web 媒体扩展", %WebMediaExtensions_Appx%, %WebMediaExtensions_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x86" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Webp 图像扩展", %WebpImageExtension_x86_Appx%, %WebpImageExtension_x86_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x64" (
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Webp 图像扩展 x86", %WebpImageExtension_x86_Appx%, %WebpImageExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Webp 图像扩展 x64", %WebpImageExtension_x64_Appx%, %WebpImageExtension_x64_License%, "%DependencyPackages%"
				)
				if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "arm64" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Webp 图像扩展", %WebpImageExtension_arm_Appx%, %WebpImageExtension_arm_License%, "%DependencyPackages%"
			)
			if "%MetroApp%" equ "FeedbackHub" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "反馈中心", %FeedbackHub_Appx%, %FeedbackHub_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "GetHelp" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "获取帮助", %GetHelp_Appx%, %GetHelp_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Getstarted" if "%ImageBuild%" leq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "入门", %Getstarted_Appx%, %Getstarted_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Getstarted" if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "使用技巧", %Getstarted_Appx%, %Getstarted_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Maps" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "地图", %Maps_Appx%, %Maps_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Messaging" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "消息", %Messaging_Appx%, %Messaging_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "MixedRealityPortal" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "混合现实门户", %MixedRealityPortal_Appx%, %MixedRealityPortal_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "OfficeHub" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "获取 Office", %OfficeHub_Appx%, %OfficeHub_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "OfficeHub" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "我的 Office", %OfficeHub_Appx%, %OfficeHub_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "OfficeOneNote" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Office OneNote", %OfficeOneNote_Appx%, %OfficeOneNote_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "OfficeSway" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Office Sway", %OfficeSway_Appx%, %OfficeSway_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "OneConnect" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "付费 WiFi 和蜂窝数据", %OneConnect_Appx%, %OneConnect_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "OneConnect" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "移动套餐", %OneConnect_Appx%, %OneConnect_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Paint3D" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "画图 3D", %Paint3D_Appx%, %Paint3D_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "People" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "人脉", %People_Appx%, %People_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Phone" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "电话", %Phone_Appx%, %Phone_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "PhoneCompanion" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "手机助手", %PhoneCompanion_Appx%, %PhoneCompanion_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Photos" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "照片", %Photos_Appx%, %Photos_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Print3D" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Print 3D", %Print3D_Appx%, %Print3D_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ScreenSketch" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "截图和草图", %ScreenSketch_Appx%, %ScreenSketch_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "SkypeApp" if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "获取 Skype 应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "SkypeApp" if "%ImageBuild%" geq "14393" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Skype 预览版应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "SkypeApp" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Skype", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "SolitaireCollection" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Solitaire Collection", %SolitaireCollection_Appx%, %SolitaireCollection_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "SoundRecorder" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "录音机", %SoundRecorder_Appx%, %SoundRecorder_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "StickyNotes" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "便笺", %StickyNotes_Appx%, %StickyNotes_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Store" (
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Microsoft Store", %Store_Appx%, %Store_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "应用商店购买应用", %StorePurchaseApp_Appx%, %StorePurchaseApp_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Identity Provider", %XboxIdentityProvider_Appx%, %XboxIdentityProvider_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Live", %XboxTCUI_Appx%, %XboxTCUI_License%, "%DependencyPackages%"
			)
			if "%MetroApp%" equ "ThreeDBuilder" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "3D Builder", %ThreeDBuilder_Appx%, %ThreeDBuilder_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ThreeDViewer" if "%ImageBuild%" equ "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "View 3D 预览版", %ThreeDViewer_Appx%, %ThreeDViewer_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ThreeDViewer" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "混合现实查看器", %ThreeDViewer_Appx%, %ThreeDViewer_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "Wallet" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Wallet", %Wallet_Appx%, %Wallet_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "WiFi" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "WiFi", %WiFi_Appx%, %WiFi_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "XboxApp" (
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox 应用", %XboxApp_Appx%, %XboxApp_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Game Overlay", %XboxGameOverlay_Appx%, %XboxGameOverlay_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Gaming Overlay", %XboxGamingOverlay_Appx%, %XboxGamingOverlay_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Identity Provider", %XboxIdentityProvider_Appx%, %XboxIdentityProvider_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox 游戏语音窗口", %XboxSpeechToTextOverlay_Appx%, %XboxSpeechToTextOverlay_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Live", %XboxTCUI_Appx%, %XboxTCUI_License%, "%DependencyPackages%"
			)
			if "%MetroApp%" equ "YourPhone" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "你的手机", %YourPhone_Appx%, %YourPhone_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ZuneMusic" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Groove 音乐", %ZuneMusic_Appx%, %ZuneMusic_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ZuneVideo" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "电影和电视", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
			if "%MetroApp%" equ "ZuneVideo" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "电影和电视", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
		)

		:: 集成所有 Microsoft 默认 Metro 应用到安装映像
		if "%MetroApp%" equ "AllApps" (
			if "%SelectedSourceOS%" equ "w81" (
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "闹钟", %Alarms_Appx%, %Alarms_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "计算器", %Calculator_Appx%, %Calculator_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "日历、邮件和人脉", %CommunicationsApps_Appx%, %CommunicationsApps_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 财经", %BingFinance_Appx%, %BingFinance_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 美食", %BingFoodDrink_Appx%, %BingFoodDrink_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 健康", %BingHealthFitness_Appx%, %BingHealthFitness_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 地图", %BingMaps_Appx%, %BingMaps_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 资讯", %BingNews_Appx%, %BingNews_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 体育", %BingSports_Appx%, %BingSports_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 旅游", %BingTravel_Appx%, %BingTravel_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "帮助和提示", %HelpAndTips_Appx%, %HelpAndTips_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Office OneNote", %OfficeOneNote_Appx%, %OfficeOneNote_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "阅读器", %Reader_Appx%, %Reader_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "阅读列表", %ReadingList_Appx%, %ReadingList_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "扫描", %Scan_Appx%, %Scan_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Skype 应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "录音机", %SoundRecorder_Appx%, %SoundRecorder_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Live 游戏", %XboxLiveGames_Appx%, %XboxLiveGames_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Zune 音乐", %ZuneMusic_Appx%, %ZuneMusic_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Zune 视频", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
			)

			if "%SelectedSourceOS%" equ "w10" (
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "闹钟和时钟", %Alarms_Appx%, %Alarms_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "10240" if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "应用连接器", %AppConnector_Appx%, %AppConnector_License%, ""
				if "%ImageBuild%" leq "10586" (
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 财经", %BingFinance_Appx%, %BingFinance_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 资讯", %BingNews_Appx%, %BingNews_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 体育", %BingSports_Appx%, %BingSports_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Bing 天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
				)
				if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "计算器", %Calculator_Appx%, %Calculator_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "相机", %Camera_Appx%, %Camera_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "日历和邮件", %CommunicationsApps_Appx%, %CommunicationsApps_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" if "%ImageBuild%" lss "17763" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "桌面应用安装程序", %DesktopAppInstaller_Appx%, %DesktopAppInstaller_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "桌面应用安装程序", %DesktopAppInstaller_Appx%, %DesktopAppInstaller_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17763" (
					if "%ImageArchitecture%" equ "x86" (
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEIF 图像扩展", %HEIFImageExtension_x86_Appx%, %HEIFImageExtension_x86_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEVC 视频扩展", %HEVCVideoExtension_x86_Appx%, %HEVCVideoExtension_x86_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "MPEG2 视频扩展", %MPEG2VideoExtension_x86_Appx%, %MPEG2VideoExtension_x86_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "VP9 视频扩展", %VP9VideoExtensions_x86_Appx%, %VP9VideoExtensions_x86_License%, "%DependencyPackages%"
					)
					if "%ImageArchitecture%" equ "x64" (
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEIF 图像扩展 x86", %HEIFImageExtension_x86_Appx%, %HEIFImageExtension_x86_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEIF 图像扩展 x64", %HEIFImageExtension_x64_Appx%, %HEIFImageExtension_x64_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEVC 视频扩展 x86", %HEVCVideoExtension_x86_Appx%, %HEVCVideoExtension_x86_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEVC 视频扩展 x64", %HEVCVideoExtension_x64_Appx%, %HEVCVideoExtension_x64_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "MPEG2 视频扩展 x86", %MPEG2VideoExtension_x86_Appx%, %MPEG2VideoExtension_x86_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "MPEG2 视频扩展 x64", %MPEG2VideoExtension_x64_Appx%, %MPEG2VideoExtension_x64_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "VP9 视频扩展 x86", %VP9VideoExtensions_x86_Appx%, %VP9VideoExtensions_x86_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "VP9 视频扩展 x64", %VP9VideoExtensions_x64_Appx%, %VP9VideoExtensions_x64_License%, "%DependencyPackages%"
					)
					if "%ImageArchitecture%" equ "arm64" (
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEIF 图像扩展", %HEIFImageExtension_arm_Appx%, %HEIFImageExtension_arm_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "HEVC 视频扩展", %HEVCVideoExtension_arm_Appx%, %HEVCVideoExtension_arm_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "MPEG2 视频扩展", %MPEG2VideoExtension_arm_Appx%, %MPEG2VideoExtension_arm_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "VP9 视频扩展", %VP9VideoExtensions_arm_Appx%, %VP9VideoExtensions_arm_License%, "%DependencyPackages%"
					)
				)
				if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Web 媒体扩展", %WebMediaExtensions_Appx%, %WebMediaExtensions_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17763" (
					if "%ImageArchitecture%" equ "x86" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Webp 图像扩展", %WebpImageExtension_x86_Appx%, %WebpImageExtension_x86_License%, "%DependencyPackages%"
					if "%ImageArchitecture%" equ "x64" (
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Webp 图像扩展 x86", %WebpImageExtension_x86_Appx%, %WebpImageExtension_x86_License%, "%DependencyPackages%"
						call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Webp 图像扩展 x64", %WebpImageExtension_x64_Appx%, %WebpImageExtension_x64_License%, "%DependencyPackages%"
					)
					if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "arm64" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Webp 图像扩展", %WebpImageExtension_arm_Appx%, %WebpImageExtension_arm_License%, "%DependencyPackages%"
				)
				if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "反馈中心", %FeedbackHub_Appx%, %FeedbackHub_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "获取帮助", %GetHelp_Appx%, %GetHelp_License%, "%DependencyPackages%"
				if "%ImageBuild%" leq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "入门", %Getstarted_Appx%, %Getstarted_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "使用技巧", %Getstarted_Appx%, %Getstarted_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "地图", %Maps_Appx%, %Maps_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "消息", %Messaging_Appx%, %Messaging_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x64" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "混合现实门户", %MixedRealityPortal_Appx%, %MixedRealityPortal_License%, "%DependencyPackages%"
				if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "获取 Office", %OfficeHub_Appx%, %OfficeHub_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "我的 Office", %OfficeHub_Appx%, %OfficeHub_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Office OneNote", %OfficeOneNote_Appx%, %OfficeOneNote_License%, "%DependencyPackages%"
				if "%ImageBuild%" equ "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Office Sway", %OfficeSway_Appx%, %OfficeSway_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "付费 WiFi 和蜂窝数据", %OneConnect_Appx%, %OneConnect_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "移动套餐", %OneConnect_Appx%, %OneConnect_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "画图 3D", %Paint3D_Appx%, %Paint3D_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "人脉", %People_Appx%, %People_License%, "%DependencyPackages%"
				if "%ImageBuild%" equ "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "电话", %Phone_Appx%, %Phone_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "10240" if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "手机助手", %PhoneCompanion_Appx%, %PhoneCompanion_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "照片", %Photos_Appx%, %Photos_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Print 3D", %Print3D_Appx%, %Print3D_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17763" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "截图和草图", %ScreenSketch_Appx%, %ScreenSketch_License%, "%DependencyPackages%"
				if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "获取 Skype 应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Skype 预览版应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Skype", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Solitaire Collection", %SolitaireCollection_Appx%, %SolitaireCollection_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "录音机", %SoundRecorder_Appx%, %SoundRecorder_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "便笺", %StickyNotes_Appx%, %StickyNotes_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Microsoft Store", %Store_Appx%, %Store_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "应用商店购买应用", %StorePurchaseApp_Appx%, %StorePurchaseApp_License%, "%DependencyPackages%"
				if "%ImageBuild%" leq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "3D Builder", %ThreeDBuilder_Appx%, %ThreeDBuilder_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "混合现实查看器", %ThreeDViewer_Appx%, %ThreeDViewer_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "15063" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "View 3D 预览版", %ThreeDViewer_Appx%, %ThreeDViewer_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Wallet", %Wallet_Appx%, %Wallet_License%, "%DependencyPackages%"
				if "%ImageBuild%" equ "10586" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "WiFi", %WiFi_Appx%, %WiFi_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox 应用", %XboxApp_Appx%, %XboxApp_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Game Overlay", %XboxGameOverlay_Appx%, %XboxGameOverlay_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Gaming Overlay", %XboxGamingOverlay_Appx%, %XboxGamingOverlay_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Identity Provider", %XboxIdentityProvider_Appx%, %XboxIdentityProvider_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox 游戏语音窗口", %XboxSpeechToTextOverlay_Appx%, %XboxSpeechToTextOverlay_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Xbox Live", %XboxTCUI_Appx%, %XboxTCUI_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17763" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "你的手机", %YourPhone_Appx%, %YourPhone_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%\%%i", "Groove 音乐", %ZuneMusic_Appx%, %ZuneMusic_License%, "%DependencyPackages%"
				if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "电影和电视", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
				if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%\%%i", "电影和电视", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
			)				
		)
	) 
) else (
	:: 集成 Windows 8.1 默认 Metro 应用到安装映像文件
	if "%SelectedSourceOS%" equ "w81" (	
		if "%MetroApp%" equ "Alarms" call :AddProvisionedAppxPackage "%InstallMount%", "闹钟", %Alarms_Appx%, %Alarms_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Calculator" call :AddProvisionedAppxPackage "%InstallMount%", "计算器", %Calculator_Appx%, %Calculator_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "CommunicationsApps" call :AddProvisionedAppxPackage "%InstallMount%", "日历、邮件和人脉", %CommunicationsApps_Appx%, %CommunicationsApps_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingFinance" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 财经", %BingFinance_Appx%, %BingFinance_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingFoodDrink" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 美食", %BingFoodDrink_Appx%, %BingFoodDrink_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingHealthFitness" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 健康", %BingHealthFitness_Appx%, %BingHealthFitness_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingMaps" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 地图", %BingMaps_Appx%, %BingMaps_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingNews" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 资讯", %BingNews_Appx%, %BingNews_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingSports" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 体育", %BingSports_Appx%, %BingSports_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingTravel" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 旅游", %BingTravel_Appx%, %BingTravel_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingWeather" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "HelpAndTips" call :AddProvisionedAppxPackage "%InstallMount%", "帮助和提示", %HelpAndTips_Appx%, %HelpAndTips_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "OfficeOneNote" call :AddProvisionedAppxPackage "%InstallMount%", "Office OneNote", %OfficeOneNote_Appx%, %OfficeOneNote_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Reader" call :AddProvisionedAppxPackage "%InstallMount%", "阅读器", %Reader_Appx%, %Reader_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ReadingList" call :AddProvisionedAppxPackage "%InstallMount%", "阅读列表", %ReadingList_Appx%, %ReadingList_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Scan" call :AddProvisionedAppxPackage "%InstallMount%", "扫描", %Scan_Appx%, %Scan_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "SkypeApp" call :AddProvisionedAppxPackage "%InstallMount%", "Skype 应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "SoundRecorder" call :AddProvisionedAppxPackage "%InstallMount%", "录音机", %SoundRecorder_Appx%, %SoundRecorder_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "XboxLiveGames" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Live 游戏", %XboxLiveGames_Appx%, %XboxLiveGames_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ZuneMusic" call :AddProvisionedAppxPackage "%InstallMount%", "Zune 音乐", %ZuneMusic_Appx%, %ZuneMusic_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ZuneVideo" call :AddProvisionedAppxPackage "%InstallMount%", "Zune 视频", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
	)

	:: 集成 Windows 10 默认 Metro 应用到安装映像
	if "%SelectedSourceOS%" equ "w10" (
		if "%MetroApp%" equ "Alarms" call :AddProvisionedAppxPackage "%InstallMount%", "闹钟和时钟", %Alarms_Appx%, %Alarms_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "AppConnector" call :AddProvisionedAppxPackage "%InstallMount%", "应用连接器", %AppConnector_Appx%, %AppConnector_License%, ""
		if "%MetroApp%" equ "BingFinance" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 财经", %BingFinance_Appx%, %BingFinance_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingNews" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 资讯", %BingNews_Appx%, %BingNews_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingSports" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 体育", %BingSports_Appx%, %BingSports_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingWeather" if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%", "Bing 天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "BingWeather" if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Calculator" call :AddProvisionedAppxPackage "%InstallMount%", "计算器", %Calculator_Appx%, %Calculator_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Camera" call :AddProvisionedAppxPackage "%InstallMount%", "相机", %Camera_Appx%, %Camera_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "CommunicationsApps" call :AddProvisionedAppxPackage "%InstallMount%", "日历和邮件", %CommunicationsApps_Appx%, %CommunicationsApps_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "DesktopAppInstaller" call :AddProvisionedAppxPackage "%InstallMount%", "桌面应用安装程序", %DesktopAppInstaller_Appx%, %DesktopAppInstaller_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Extensions" (
			if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x86" (
				call :AddProvisionedAppxPackage "%InstallMount%", "HEIF 图像扩展", %HEIFImageExtension_x86_Appx%, %HEIFImageExtension_x86_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "HEVC 视频扩展", %HEVCVideoExtension_x86_Appx%, %HEVCVideoExtension_x86_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "MPEG2 视频扩展", %MPEG2VideoExtension_x86_Appx%, %MPEG2VideoExtension_x86_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "VP9 视频扩展", %VP9VideoExtensions_x86_Appx%, %VP9VideoExtensions_x86_License%, "%DependencyPackages%"
			)
			if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x64" (
				call :AddProvisionedAppxPackage "%InstallMount%", "HEIF 图像扩展 x86", %HEIFImageExtension_x86_Appx%, %HEIFImageExtension_x86_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "HEIF 图像扩展 x64", %HEIFImageExtension_x64_Appx%, %HEIFImageExtension_x64_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "HEVC 视频扩展 x86", %HEVCVideoExtension_x86_Appx%, %HEVCVideoExtension_x86_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "HEVC 视频扩展 x64", %HEVCVideoExtension_x64_Appx%, %HEVCVideoExtension_x64_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "MPEG2 视频扩展 x86", %MPEG2VideoExtension_x86_Appx%, %MPEG2VideoExtension_x86_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "MPEG2 视频扩展 x64", %MPEG2VideoExtension_x64_Appx%, %MPEG2VideoExtension_x64_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "VP9 视频扩展 x86", %VP9VideoExtensions_x86_Appx%, %VP9VideoExtensions_x86_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "VP9 视频扩展 x64", %VP9VideoExtensions_x64_Appx%, %VP9VideoExtensions_x64_License%, "%DependencyPackages%"
			)
			if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "arm64" (
				call :AddProvisionedAppxPackage "%InstallMount%", "HEIF 图像扩展", %HEIFImageExtension_arm_Appx%, %HEIFImageExtension_arm_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "HEVC 视频扩展", %HEVCVideoExtension_arm_Appx%, %HEVCVideoExtension_arm_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "MPEG2 视频扩展", %MPEG2VideoExtension_arm_Appx%, %MPEG2VideoExtension_arm_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "VP9 视频扩展", %VP9VideoExtensions_arm_Appx%, %VP9VideoExtensions_arm_License%, "%DependencyPackages%"
			)
			call :AddProvisionedAppxPackage "%InstallMount%", "Web 媒体扩展", %WebMediaExtensions_Appx%, %WebMediaExtensions_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x86" call :AddProvisionedAppxPackage "%InstallMount%", "Webp 图像扩展", %WebpImageExtension_x86_Appx%, %WebpImageExtension_x86_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x64" (
				call :AddProvisionedAppxPackage "%InstallMount%", "Webp 图像扩展 x86", %WebpImageExtension_x86_Appx%, %WebpImageExtension_x86_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "Webp 图像扩展 x64", %WebpImageExtension_x64_Appx%, %WebpImageExtension_x64_License%, "%DependencyPackages%"
			)
			if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "arm64" call :AddProvisionedAppxPackage "%InstallMount%", "Webp 图像扩展", %WebpImageExtension_arm_Appx%, %WebpImageExtension_arm_License%, "%DependencyPackages%"
		)
		if "%MetroApp%" equ "FeedbackHub" call :AddProvisionedAppxPackage "%InstallMount%", "反馈中心", %FeedbackHub_Appx%, %FeedbackHub_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "GetHelp" call :AddProvisionedAppxPackage "%InstallMount%", "获取帮助", %GetHelp_Appx%, %GetHelp_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Getstarted" if "%ImageBuild%" leq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "入门", %Getstarted_Appx%, %Getstarted_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Getstarted" if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "使用技巧", %Getstarted_Appx%, %Getstarted_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Maps" call :AddProvisionedAppxPackage "%InstallMount%", "地图", %Maps_Appx%, %Maps_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Messaging" call :AddProvisionedAppxPackage "%InstallMount%", "消息", %Messaging_Appx%, %Messaging_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "MixedRealityPortal" call :AddProvisionedAppxPackage "%InstallMount%", "混合现实门户", %MixedRealityPortal_Appx%, %MixedRealityPortal_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "OfficeHub" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "获取 Office", %OfficeHub_Appx%, %OfficeHub_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "OfficeHub" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "我的 Office", %OfficeHub_Appx%, %OfficeHub_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "OfficeOneNote" call :AddProvisionedAppxPackage "%InstallMount%", "Office OneNote", %OfficeOneNote_Appx%, %OfficeOneNote_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "OfficeSway" call :AddProvisionedAppxPackage "%InstallMount%", "Office Sway", %OfficeSway_Appx%, %OfficeSway_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "OneConnect" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "付费 WiFi 和蜂窝数据", %OneConnect_Appx%, %OneConnect_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "OneConnect" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "移动套餐", %OneConnect_Appx%, %OneConnect_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Paint3D" call :AddProvisionedAppxPackage "%InstallMount%", "画图 3D", %Paint3D_Appx%, %Paint3D_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "People" call :AddProvisionedAppxPackage "%InstallMount%", "人脉", %People_Appx%, %People_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Phone" call :AddProvisionedAppxPackage "%InstallMount%", "电话", %Phone_Appx%, %Phone_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "PhoneCompanion" call :AddProvisionedAppxPackage "%InstallMount%", "手机助手", %PhoneCompanion_Appx%, %PhoneCompanion_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Photos" call :AddProvisionedAppxPackage "%InstallMount%", "照片", %Photos_Appx%, %Photos_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Print3D" call :AddProvisionedAppxPackage "%InstallMount%", "Print 3D", %Print3D_Appx%, %Print3D_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ScreenSketch" call :AddProvisionedAppxPackage "%InstallMount%", "截图和草图", %ScreenSketch_Appx%, %ScreenSketch_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "SkypeApp" if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%", "获取 Skype 应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "SkypeApp" if "%ImageBuild%" geq "14393" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "Skype 预览版应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "SkypeApp" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "Skype", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "SolitaireCollection" call :AddProvisionedAppxPackage "%InstallMount%", "Solitaire Collection", %SolitaireCollection_Appx%, %SolitaireCollection_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "SoundRecorder" call :AddProvisionedAppxPackage "%InstallMount%", "录音机", %SoundRecorder_Appx%, %SoundRecorder_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "StickyNotes" call :AddProvisionedAppxPackage "%InstallMount%", "便笺", %StickyNotes_Appx%, %StickyNotes_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Store" (
			call :AddProvisionedAppxPackage "%InstallMount%", "Microsoft Store", %Store_Appx%, %Store_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "应用商店购买应用", %StorePurchaseApp_Appx%, %StorePurchaseApp_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Identity Provider", %XboxIdentityProvider_Appx%, %XboxIdentityProvider_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Live", %XboxTCUI_Appx%, %XboxTCUI_License%, "%DependencyPackages%"
		)
		if "%MetroApp%" equ "ThreeDBuilder" call :AddProvisionedAppxPackage "%InstallMount%", "3D Builder", %ThreeDBuilder_Appx%, %ThreeDBuilder_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ThreeDViewer" if "%ImageBuild%" equ "16299" call :AddProvisionedAppxPackage "%InstallMount%", "View 3D 预览版", %ThreeDViewer_Appx%, %ThreeDViewer_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ThreeDViewer" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "混合现实查看器", %ThreeDViewer_Appx%, %ThreeDViewer_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "Wallet" call :AddProvisionedAppxPackage "%InstallMount%", "Wallet", %Wallet_Appx%, %Wallet_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "WiFi" call :AddProvisionedAppxPackage "%InstallMount%", "WiFi", %WiFi_Appx%, %WiFi_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "XboxApp" (
			call :AddProvisionedAppxPackage "%InstallMount%", "Xbox 应用", %XboxApp_Appx%, %XboxApp_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Game Overlay", %XboxGameOverlay_Appx%, %XboxGameOverlay_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Gaming Overlay", %XboxGamingOverlay_Appx%, %XboxGamingOverlay_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Identity Provider", %XboxIdentityProvider_Appx%, %XboxIdentityProvider_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox 游戏语音窗口", %XboxSpeechToTextOverlay_Appx%, %XboxSpeechToTextOverlay_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Live", %XboxTCUI_Appx%, %XboxTCUI_License%, "%DependencyPackages%"
		)
		if "%MetroApp%" equ "YourPhone" call :AddProvisionedAppxPackage "%InstallMount%", "你的手机", %YourPhone_Appx%, %YourPhone_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ZuneMusic" call :AddProvisionedAppxPackage "%InstallMount%", "Groove 音乐", %ZuneMusic_Appx%, %ZuneMusic_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ZuneVideo" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "电影和电视", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
		if "%MetroApp%" equ "ZuneVideo" if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "电影和电视", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
	)

	:: 集成所有 Microsoft 默认 Metro 应用到安装映像
	if "%MetroApp%" equ "AllApps" (
		if "%SelectedSourceOS%" equ "w81" (
			call :AddProvisionedAppxPackage "%InstallMount%", "闹钟", %Alarms_Appx%, %Alarms_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "计算器", %Calculator_Appx%, %Calculator_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "日历、邮件和人脉", %CommunicationsApps_Appx%, %CommunicationsApps_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Bing 财经", %BingFinance_Appx%, %BingFinance_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Bing 美食", %BingFoodDrink_Appx%, %BingFoodDrink_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Bing 健康", %BingHealthFitness_Appx%, %BingHealthFitness_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Bing 地图", %BingMaps_Appx%, %BingMaps_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Bing 资讯", %BingNews_Appx%, %BingNews_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Bing 体育", %BingSports_Appx%, %BingSports_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Bing 旅游", %BingTravel_Appx%, %BingTravel_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Bing 天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "帮助和提示", %HelpAndTips_Appx%, %HelpAndTips_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Office OneNote", %OfficeOneNote_Appx%, %OfficeOneNote_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "阅读器", %Reader_Appx%, %Reader_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "阅读列表", %ReadingList_Appx%, %ReadingList_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "扫描", %Scan_Appx%, %Scan_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Skype 应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "录音机", %SoundRecorder_Appx%, %SoundRecorder_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Live 游戏", %XboxLiveGames_Appx%, %XboxLiveGames_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Zune 音乐", %ZuneMusic_Appx%, %ZuneMusic_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Zune 视频", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
		)

		if "%SelectedSourceOS%" equ "w10" (
			call :AddProvisionedAppxPackage "%InstallMount%", "闹钟和时钟", %Alarms_Appx%, %Alarms_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "10240" if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%", "应用连接器", %AppConnector_Appx%, %AppConnector_License%, ""
			if "%ImageBuild%" leq "10586" (
				call :AddProvisionedAppxPackage "%InstallMount%", "Bing 财经", %BingFinance_Appx%, %BingFinance_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "Bing 资讯", %BingNews_Appx%, %BingNews_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "Bing 体育", %BingSports_Appx%, %BingSports_License%, "%DependencyPackages%"
				call :AddProvisionedAppxPackage "%InstallMount%", "Bing 天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
			)
			if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "天气", %BingWeather_Appx%, %BingWeather_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "计算器", %Calculator_Appx%, %Calculator_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "相机", %Camera_Appx%, %Camera_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "日历和邮件", %CommunicationsApps_Appx%, %CommunicationsApps_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" if "%ImageBuild%" lss "17763" call :AddProvisionedAppxPackage "%InstallMount%", "桌面应用安装程序", %DesktopAppInstaller_Appx%, %DesktopAppInstaller_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "桌面应用安装程序", %DesktopAppInstaller_Appx%, %DesktopAppInstaller_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17763" (
				if "%ImageArchitecture%" equ "x86" (
					call :AddProvisionedAppxPackage "%InstallMount%", "HEIF 图像扩展", %HEIFImageExtension_x86_Appx%, %HEIFImageExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "HEVC 视频扩展", %HEVCVideoExtension_x86_Appx%, %HEVCVideoExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "MPEG2 视频扩展", %MPEG2VideoExtension_x86_Appx%, %MPEG2VideoExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "VP9 视频扩展", %VP9VideoExtensions_x86_Appx%, %VP9VideoExtensions_x86_License%, "%DependencyPackages%"
				)
				if "%ImageArchitecture%" equ "x64" (
					call :AddProvisionedAppxPackage "%InstallMount%", "HEIF 图像扩展 x86", %HEIFImageExtension_x86_Appx%, %HEIFImageExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "HEIF 图像扩展 x64", %HEIFImageExtension_x64_Appx%, %HEIFImageExtension_x64_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "HEVC 视频扩展 x86", %HEVCVideoExtension_x86_Appx%, %HEVCVideoExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "HEVC 视频扩展 x64", %HEVCVideoExtension_x64_Appx%, %HEVCVideoExtension_x64_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "MPEG2 视频扩展 x86", %MPEG2VideoExtension_x86_Appx%, %MPEG2VideoExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "MPEG2 视频扩展 x64", %MPEG2VideoExtension_x64_Appx%, %MPEG2VideoExtension_x64_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "VP9 视频扩展 x86", %VP9VideoExtensions_x86_Appx%, %VP9VideoExtensions_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "VP9 视频扩展 x64", %VP9VideoExtensions_x64_Appx%, %VP9VideoExtensions_x64_License%, "%DependencyPackages%"
				)
				if "%ImageArchitecture%" equ "arm64" (
					call :AddProvisionedAppxPackage "%InstallMount%", "HEIF 图像扩展", %HEIFImageExtension_arm_Appx%, %HEIFImageExtension_arm_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "HEVC 视频扩展", %HEVCVideoExtension_arm_Appx%, %HEVCVideoExtension_arm_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "MPEG2 视频扩展", %MPEG2VideoExtension_arm_Appx%, %MPEG2VideoExtension_arm_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "VP9 视频扩展", %VP9VideoExtensions_arm_Appx%, %VP9VideoExtensions_arm_License%, "%DependencyPackages%"
				)
			)
			if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "Web 媒体扩展", %WebMediaExtensions_Appx%, %WebMediaExtensions_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17763" (
				if "%ImageArchitecture%" equ "x86" call :AddProvisionedAppxPackage "%InstallMount%", "Webp 图像扩展", %WebpImageExtension_x86_Appx%, %WebpImageExtension_x86_License%, "%DependencyPackages%"
				if "%ImageArchitecture%" equ "x64" (
					call :AddProvisionedAppxPackage "%InstallMount%", "Webp 图像扩展 x86", %WebpImageExtension_x86_Appx%, %WebpImageExtension_x86_License%, "%DependencyPackages%"
					call :AddProvisionedAppxPackage "%InstallMount%", "Webp 图像扩展 x64", %WebpImageExtension_x64_Appx%, %WebpImageExtension_x64_License%, "%DependencyPackages%"
				)
				if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "arm64" call :AddProvisionedAppxPackage "%InstallMount%", "Webp 图像扩展", %WebpImageExtension_arm_Appx%, %WebpImageExtension_arm_License%, "%DependencyPackages%"
			)
			if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "反馈中心", %FeedbackHub_Appx%, %FeedbackHub_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "获取帮助", %GetHelp_Appx%, %GetHelp_License%, "%DependencyPackages%"
			if "%ImageBuild%" leq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "入门", %Getstarted_Appx%, %Getstarted_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "使用技巧", %Getstarted_Appx%, %Getstarted_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "地图", %Maps_Appx%, %Maps_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "10586" call :AddProvisionedAppxPackage "%InstallMount%", "消息", %Messaging_Appx%, %Messaging_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17763" if "%ImageArchitecture%" equ "x64" call :AddProvisionedAppxPackage "%InstallMount%", "混合现实门户", %MixedRealityPortal_Appx%, %MixedRealityPortal_License%, "%DependencyPackages%"
			if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "获取 Office", %OfficeHub_Appx%, %OfficeHub_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "我的 Office", %OfficeHub_Appx%, %OfficeHub_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Office OneNote", %OfficeOneNote_Appx%, %OfficeOneNote_License%, "%DependencyPackages%"
			if "%ImageBuild%" equ "10586" call :AddProvisionedAppxPackage "%InstallMount%", "Office Sway", %OfficeSway_Appx%, %OfficeSway_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "付费 WiFi 和蜂窝数据", %OneConnect_Appx%, %OneConnect_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "移动套餐", %OneConnect_Appx%, %OneConnect_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "画图 3D", %Paint3D_Appx%, %Paint3D_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "人脉", %People_Appx%, %People_License%, "%DependencyPackages%"
			if "%ImageBuild%" equ "10586" call :AddProvisionedAppxPackage "%InstallMount%", "电话", %Phone_Appx%, %Phone_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "10240" if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%", "手机助手", %PhoneCompanion_Appx%, %PhoneCompanion_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "照片", %Photos_Appx%, %Photos_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "Print 3D", %Print3D_Appx%, %Print3D_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17763" call :AddProvisionedAppxPackage "%InstallMount%", "截图和草图", %ScreenSketch_Appx%, %ScreenSketch_License%, "%DependencyPackages%"
			if "%ImageBuild%" leq "10586" call :AddProvisionedAppxPackage "%InstallMount%", "获取 Skype 应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "Skype 预览版应用", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "Skype", %SkypeApp_Appx%, %SkypeApp_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Solitaire Collection", %SolitaireCollection_Appx%, %SolitaireCollection_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "录音机", %SoundRecorder_Appx%, %SoundRecorder_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "便笺", %StickyNotes_Appx%, %StickyNotes_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Microsoft Store", %Store_Appx%, %Store_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "应用商店购买应用", %StorePurchaseApp_Appx%, %StorePurchaseApp_License%, "%DependencyPackages%"
			if "%ImageBuild%" leq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "3D Builder", %ThreeDBuilder_Appx%, %ThreeDBuilder_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "混合现实查看器", %ThreeDViewer_Appx%, %ThreeDViewer_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "15063" if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "View 3D 预览版", %ThreeDViewer_Appx%, %ThreeDViewer_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "Wallet", %Wallet_Appx%, %Wallet_License%, "%DependencyPackages%"
			if "%ImageBuild%" equ "10586" call :AddProvisionedAppxPackage "%InstallMount%", "WiFi", %WiFi_Appx%, %WiFi_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Xbox 应用", %XboxApp_Appx%, %XboxApp_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Game Overlay", %XboxGameOverlay_Appx%, %XboxGameOverlay_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Gaming Overlay", %XboxGamingOverlay_Appx%, %XboxGamingOverlay_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "14393" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Identity Provider", %XboxIdentityProvider_Appx%, %XboxIdentityProvider_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "15063" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox 游戏语音窗口", %XboxSpeechToTextOverlay_Appx%, %XboxSpeechToTextOverlay_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "Xbox Live", %XboxTCUI_Appx%, %XboxTCUI_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17763" call :AddProvisionedAppxPackage "%InstallMount%", "你的手机", %YourPhone_Appx%, %YourPhone_License%, "%DependencyPackages%"
			call :AddProvisionedAppxPackage "%InstallMount%", "Groove 音乐", %ZuneMusic_Appx%, %ZuneMusic_License%, "%DependencyPackages%"
			if "%ImageBuild%" geq "17134" call :AddProvisionedAppxPackage "%InstallMount%", "电影和电视", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
			if "%ImageBuild%" leq "16299" call :AddProvisionedAppxPackage "%InstallMount%", "电影和电视", %ZuneVideo_Appx%, %ZuneVideo_License%, "%DependencyPackages%"
		)			
	)
)
echo.-------------------------------------------------------------------------------
echo.####集成默认 Metro 应用已完成##################################################
echo.-------------------------------------------------------------------------------
echo.
:Stop
echo.===============================================================================
echo.
pause

set Apps=
set MetroApp=

set Alarms_Appx=
set AppConnector_Appx=
set BingFinance_Appx=
set BingFoodDrink_Appx=
set BingHealthFitness_Appx=
set BingMaps_Appx=
set BingNews_Appx=
set BingSports_Appx=
set BingTravel_Appx=
set BingWeather_Appx=
set Calculator_Appx=
set Camera_Appx=
set CommunicationsApps_Appx=
set DesktopAppInstaller_Appx=
set FeedbackHub_Appx=
set GetHelp_Appx=
set Getstarted_Appx=
set HEIFImageExtension_arm_Appx=
set HEIFImageExtension_x86_Appx=
set HEIFImageExtension_x64_Appx=
set HEVCVideoExtension_arm_Appx=
set HEVCVideoExtension_x86_Appx=
set HEVCVideoExtension_x64_Appx=
set HelpAndTips_Appx=
set Maps_Appx=
set Messaging_Appx=
set MixedRealityPortal_Appx=
set MPEG2VideoExtension_arm_Appx=
set MPEG2VideoExtension_x86_Appx=
set MPEG2VideoExtension_x64_Appx=
set OfficeHub_Appx=
set OfficeOneNote_Appx=
set OfficeSway_Appx=
set OneConnect_Appx=
set Paint3D_Appx=
set People_Appx=
set Phone_Appx=
set PhoneCompanion_Appx=
set Photos_Appx=
set Print3D_Appx=
set Reader_Appx=
set ReadingList_Appx=
set Scan_Appx=
set ScreenSketch_Appx=
set Skype_Appx=
set SolitaireCollection_Appx=
set SoundRecorder_Appx=
set StickyNotes_Appx=
set Store_Appx=
set StorePurchase_Appx=
set ThreeDBuilder_Appx=
set ThreeDViewer_Appx=
set VP9VideoExtensions_arm_Appx=
set VP9VideoExtensions_x86_Appx=
set VP9VideoExtensions_x64_Appx=
set Wallet_Appx=
set WebMediaExtensions_Appx=
set WebpImageExtension_arm_Appx=
set WebpImageExtension_x86_Appx=
set WebpImageExtension_x64_Appx=
set WiFi_Appx=
set Xbox_Appx=
set XboxGameOverlay_Appx=
set XboxGamingOverlay_Appx=
set XboxIdentityProvider_Appx=
set XboxLiveGames_Appx=
set XboxSpeechToTextOverlay_Appx=
set XboxTCUI_Appx=
set YourPhone_Appx=
set ZuneMusic_Appx=
set ZuneVideo_Appx=

set Alarms_License=
set AppConnector_License=
set BingFinance_License=
set BingFoodDrink_License=
set BingHealthFitness_License=
set BingMaps_License=
set BingNews_License=
set BingSports_License=
set BingTravel_License=
set BingWeather_License=
set Calculator_License=
set Camera_License=
set CommunicationsApps_License=
set DesktopAppInstaller_License=
set FeedbackHub_License=
set GetHelp_License=
set Getstarted_License=
set HEIFImageExtension_arm_License=
set HEIFImageExtension_x86_License=
set HEIFImageExtension_x64_License=
set HEVCVideoExtension_arm_License=
set HEVCVideoExtension_x86_License=
set HEVCVideoExtension_x64_License=
set HelpAndTips_License=
set Maps_License=
set Messaging_License=
set MixedRealityPortal_License=
set MPEG2VideoExtension_arm_License=
set MPEG2VideoExtension_x86_License=
set MPEG2VideoExtension_x64_License=
set OfficeHub_License=
set OfficeOneNote_License=
set OfficeSway_License=
set OneConnect_License=
set Paint3D_License=
set People_License=
set Phone_License=
set PhoneCompanion_License=
set Photos_License=
set Print3D_License=
set Reader_License=
set ReadingList_License=
set Scan_License=
set ScreenSketch_License=
set Skype_License=
set SolitaireCollection_License=
set SoundRecorder_License=
set StickyNotes_License=
set Store_License=
set StorePurchase_License=
set ThreeDBuilder_License=
set ThreeDViewer_License=
set VP9VideoExtensions_arm_License=
set VP9VideoExtensions_x86_License=
set VP9VideoExtensions_x64_License=
set Wallet_License=
set WebMediaExtensions_License=
set WebpImageExtension_arm_License=
set WebpImageExtension_x86_License=
set WebpImageExtension_x64_License=
set WiFi_License=
set Xbox_License=
set XboxGameOverlay_License=
set XboxGamingOverlay_License=
set XboxIdentityProvider_License=
set XboxLiveGames_License=
set XboxSpeechToTextOverlay_License=
set XboxTCUI_License=
set YourPhone_License=
set ZuneMusic_License=
set ZuneVideo_License=

set AdvertisingXaml_arm_Appx=
set AdvertisingXaml_arm64_Appx=
set AdvertisingXaml_x86_Appx=
set AdvertisingXaml_x64_Appx=
set MediaPlayReadyClient22_arm_Appx=
set MediaPlayReadyClient22_x86_Appx=
set MediaPlayReadyClient22_x64_Appx=
set NETNativeFramework13_arm_Appx=
set NETNativeFramework13_x86_Appx=
set NETNativeFramework13_x64_Appx=
set NETNativeFramework16_arm_Appx=
set NETNativeFramework16_x86_Appx=
set NETNativeFramework16_x64_Appx=
set NETNativeFramework17_arm_Appx=
set NETNativeFramework17_x86_Appx=
set NETNativeFramework17_x64_Appx=
set NETNativeFramework21_arm_Appx=
set NETNativeFramework21_x86_Appx=
set NETNativeFramework21_x64_Appx=
set NETNativeFramework22_arm_Appx=
set NETNativeFramework22_arm64_Appx=
set NETNativeFramework22_x86_Appx=
set NETNativeFramework22_x64_Appx=
set NETNativeRuntime13_arm_Appx=
set NETNativeRuntime13_x86_Appx=
set NETNativeRuntime13_x64_Appx=
set NETNativeRuntime14_arm_Appx=
set NETNativeRuntime14_x86_Appx=
set NETNativeRuntime14_x64_Appx=
set NETNativeRuntime16_arm_Appx=
set NETNativeRuntime16_x86_Appx=
set NETNativeRuntime16_x64_Appx=
set NETNativeRuntime17_arm_Appx=
set NETNativeRuntime17_x86_Appx=
set NETNativeRuntime17_x64_Appx=
set NETNativeRuntime21_arm_Appx=
set NETNativeRuntime21_x86_Appx=
set NETNativeRuntime21_x64_Appx=
set NETNativeRuntime22_arm_Appx=
set NETNativeRuntime22_arm64_Appx=
set NETNativeRuntime22_x86_Appx=
set NETNativeRuntime22_x64_Appx=
set ServicesStoreEngagement_arm_Appx=
set ServicesStoreEngagement_arm64_Appx=
set ServicesStoreEngagement_x86_Appx=
set ServicesStoreEngagement_x64_Appx=
set UIXaml20_arm_Appx=
set UIXaml20_arm64_Appx=
set UIXaml20_x86_Appx=
set UIXaml20_x64_Appx=
set UIXaml21_arm_Appx=
set UIXaml21_arm64_Appx=
set UIXaml21_x86_Appx=
set UIXaml21_x64_Appx=
set VCLibs12_arm_Appx=
set VCLibs12_x86_Appx=
set VCLibs12_x64_Appx=
set VCLibs14_arm_Appx=
set VCLibs14_arm64_Appx=
set VCLibs14_x86_Appx=
set VCLibs14_x64_Appx=
set VCLibsUWPDesktop14_arm_Appx=
set VCLibsUWPDesktop14_arm64_Appx=
set VCLibsUWPDesktop14_x86_Appx=
set VCLibsUWPDesktop14_x64_Appx=
set WinJS20_Appx=

set AdvertisingXaml=
set DependencyPackages=
set NETNativeFramework13=
set NETNativeFramework16=
set NETNativeFramework17=
set NETNativeFramework21=
set NETNativeFramework22=
set NETNativeRuntime13=
set NETNativeRuntime14=
set NETNativeRuntime16=
set NETNativeRuntime17=
set NETNativeRuntime21=
set NETNativeRuntime22=
set ServicesStoreEngagement=
set UIXaml20=
set UIXaml21=
set VCLibs14=
set VCLibsUWPDesktop14=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 集成 Microsoft Office 桌面通用 Windows 平台（UWP）应用
::-------------------------------------------------------------------------------------------
:IntOfficeUWPApps

setlocal

set OfficeUWPApp=
set OfficeDesktop_Appx=
set OfficeAccess_Appx=
set OfficeExcel_Appx=
set OfficeOutlook_Appx=
set OfficePowerPoint_Appx=
set OfficePublisher_Appx=
set OfficeWord_Appx=

set OfficeDesktop_License=
set OfficeAccess_License=
set OfficeExcel_License=
set OfficeOutlook_License=
set OfficePowerPoint_License=
set OfficePublisher_License=
set OfficeWord_License=

cls
echo.===============================================================================
echo.             MSMG 工具箱 - 集成 Microsoft Office 桌面 ^(UWP^) 应用
echo.===============================================================================
echo.
:: 检查 Microsoft Office 桌面（UWP）应用文件夹是否是空的
if not exist "%OfficeUWP%\*.appxbundle" (
	echo.Microsoft Office 桌面 ^(UWP^) 应用包文件夹 ^<Packs\%OfficeUWP%^> 是空的……
	echo.
	echo.请复制 Microsoft Office 桌面 ^(UWP^) 应用包文件到相应文件夹……
	echo.
	goto :Stop
)

if not exist "%OfficeUWP%\*.xml" (
	echo.Microsoft Office 桌面 ^(UWP^) 应用包文件夹 ^<Packs\%OfficeUWP%^> 是空的……
	echo.
	echo.请复制 Microsoft Office 桌面 ^(UWP^) 应用包文件到相应文件夹……
	echo.
	goto :Stop
)

cls
echo.===============================================================================
echo.           MSMG 工具箱 - 集成 Microsoft Office 桌面 ^(UWP^) 应用菜单
echo.===============================================================================
echo.
echo.  [1]  Microsoft Office Access 2016
echo.
echo.  [2]  Microsoft Office Excel 2016
echo.
echo.  [3]  Microsoft Office Outlook 2016
echo.
echo.  [4]  Microsoft Office PowerPoint 2016
echo.
echo.  [5]  Microsoft Office Publisher 2016
echo.
echo.  [6]  Microsoft Office Word 2016
echo.
echo.
echo.  [A]  所有应用
echo.
echo.  [X]  返回
echo.
echo.===============================================================================
echo.
choice /C:123456AX /N /M "请输入你的选项 ："

if errorlevel 8 goto :IntFeatures
if errorlevel 7 set "OfficeUWPApp=AllOfficeApps"
if errorlevel 6 set "OfficeUWPApp=OfficeWord"
if errorlevel 5 set "OfficeUWPApp=OfficePublisher"
if errorlevel 4 set "OfficeUWPApp=OfficePowerPoint"
if errorlevel 3 set "OfficeUWPApp=OfficeOutlook"
if errorlevel 2 set "OfficeUWPApp=OfficeExcel"
if errorlevel 1 set "OfficeUWPApp=OfficeAccess"

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 获取 Microsoft Office 桌面（UWP）应用文件完整路径名称
cd /d "%OfficeUWP%\"

for /f %%i IN ('"dir /b *Microsoft.Office.Desktop_*.appxbundle" 2^>nul') do if exist %%i set "OfficeDesktop_Appx=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Access_*.appxbundle" 2^>nul') do if exist %%i set "OfficeAccess_Appx=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Excel_*.appxbundle" 2^>nul') do if exist %%i set "OfficeExcel_Appx=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Outlook_*.appxbundle" 2^>nul') do if exist %%i set "OfficeOutlook_Appx=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.PowerPoint*.appxbundle" 2^>nul') do if exist %%i set "OfficePowerPoint_Appx=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Publisher_*.appxbundle" 2^>nul') do if exist %%i set "OfficePublisher_Appx=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Word_*.appxbundle" 2^>nul') do if exist %%i set "OfficeWord_Appx=%OfficeUWP%\%%i"

for /f %%i IN ('"dir /b *Microsoft.Office.Desktop_*.xml" 2^>nul') do if exist %%i set "OfficeDesktop_License=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Access_*.xml" 2^>nul') do if exist %%i set "OfficeAccess_License=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Excel_*.xml" 2^>nul') do if exist %%i set "OfficeExcel_License=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Outlook_*.xml" 2^>nul') do if exist %%i set "OfficeOutlook_License=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.PowerPoint_*.xml" 2^>nul') do if exist %%i set "OfficePowerPoint_License=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Publisher_*.xml" 2^>nul') do if exist %%i set "OfficePublisher_License=%OfficeUWP%\%%i"
for /f %%i IN ('"dir /b *Microsoft.Office.Desktop.Word_*.xml" 2^>nul') do if exist %%i set "OfficeWord_License=%OfficeUWP%\%%i"

cd /d "%ROOT%\"

cls
echo.===============================================================================
echo.             MSMG 工具箱 - 集成 Microsoft Office 桌面 ^(UWP^) 应用
echo.===============================================================================
echo.
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft Office 桌面 ^(UWP^) 应用##############################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%OfficeUWPApp%" equ "AllOfficeApps"	echo.####正在集成 Microsoft Office 桌面 ^(UWP^) 应用##################################
if "%OfficeUWPApp%" equ "OfficeAccess" echo.####正在集成 Microsoft Office 桌面 - Access ^(UWP^) 应用#########################
if "%OfficeUWPApp%" equ "OfficeExcel" echo.####正在集成 Microsoft Office 桌面 - Excel ^(UWP^) 应用##########################
if "%OfficeUWPApp%" equ "OfficeOutlook" echo.####正在集成 Microsoft Office 桌面 - Outlook ^(UWP^) 应用########################
if "%OfficeUWPApp%" equ "OfficePowerPoint" echo.####正在集成 Microsoft Office 桌面 - PowerPoint ^(UWP^) 应用#####################
if "%OfficeUWPApp%" equ "OfficePublisher" echo.####正在集成 Microsoft Office 桌面 - Publisher ^(UWP^) 应用###################
if "%OfficeUWPApp%" equ "OfficeWord" echo.####正在集成 Microsoft Office 桌面 - Word ^(UWP^) 应用###########################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		
		if "%OfficeUWPApp%" equ "OfficeAccess" %DISM% /Image:"%InstallMount%\%%i" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeAccess_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeAccess_License%
		if "%OfficeUWPApp%" equ "OfficeExcel" %DISM% /Image:"%InstallMount%\%%i" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeExcel_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeExcel_License%
		if "%OfficeUWPApp%" equ "OfficeOutlook" %DISM% /Image:"%InstallMount%\%%i" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeOutlook_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeOutlook_License%
		if "%OfficeUWPApp%" equ "OfficePowerPoint" %DISM% /Image:"%InstallMount%\%%i" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficePowerPoint_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficePowerPoint_License%
		if "%OfficeUWPApp%" equ "OfficePublisher" %DISM% /Image:"%InstallMount%\%%i" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficePublisher_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficePublisher_License%
		if "%OfficeUWPApp%" equ "OfficeWord" %DISM% /Image:"%InstallMount%\%%i" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeWord_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeWord_License%
		if "%OfficeUWPApp%" equ "AllOfficeApps"	%DISM% /Image:"%InstallMount%\%%i" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeAccess_Appx% /OptionalPackagePath=%OfficeExcel_Appx% /OptionalPackagePath=%OfficeOutlook_Appx% /OptionalPackagePath=%OfficePowerPoint_Appx% /OptionalPackagePath=%OfficePublisher_Appx% /OptionalPackagePath=%OfficeWord_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeAccess_License% /LicensePath:%OfficeExcel_License% /LicensePath:%OfficeOutlook_License% /LicensePath:%OfficePowerPoint_License% /LicensePath:%OfficePublisher_License% /LicensePath:%OfficeWord_License%
	) 
) else (
	if "%OfficeUWPApp%" equ "OfficeAccess" %DISM% /Image:"%InstallMount%" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeAccess_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeAccess_License%
	if "%OfficeUWPApp%" equ "OfficeExcel" %DISM% /Image:"%InstallMount%" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeExcel_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeExcel_License%
	if "%OfficeUWPApp%" equ "OfficeOutlook" %DISM% /Image:"%InstallMount%" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeOutlook_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeOutlook_License%
	if "%OfficeUWPApp%" equ "OfficePowerPoint" %DISM% /Image:"%InstallMount%" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficePowerPoint_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficePowerPoint_License%
	if "%OfficeUWPApp%" equ "OfficePublisher" %DISM% /Image:"%InstallMount%" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficePublisher_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficePublisher_License%
	if "%OfficeUWPApp%" equ "OfficeWord" %DISM% /Image:"%InstallMount%" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeWord_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeWord_License%
	if "%OfficeUWPApp%" equ "AllOfficeApps"	%DISM% /Image:"%InstallMount%" /Add-ProvisionedAppxPackage /PackagePath:%OfficeDesktop_Appx% /OptionalPackagePath=%OfficeAccess_Appx% /OptionalPackagePath=%OfficeExcel_Appx% /OptionalPackagePath=%OfficeOutlook_Appx% /OptionalPackagePath=%OfficePowerPoint_Appx% /OptionalPackagePath=%OfficePublisher_Appx% /OptionalPackagePath=%OfficeWord_Appx% /LicensePath:%OfficeDesktop_License% /LicensePath:%OfficeAccess_License% /LicensePath:%OfficeExcel_License% /LicensePath:%OfficeOutlook_License% /LicensePath:%OfficePowerPoint_License% /LicensePath:%OfficePublisher_License% /LicensePath:%OfficeWord_License%
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft Office 桌面 ^(UWP^) 应用已完成################################
echo.-------------------------------------------------------------------------------
echo.
:Stop
echo.===============================================================================
echo.
pause

set OfficeUWPApp=
set OfficeDesktop_Appx=
set OfficeAccess_Appx=
set OfficeExcel_Appx=
set OfficeOutlook_Appx=
set OfficePowerPoint_Appx=
set OfficePublisher_Appx=
set OfficeWord_Appx=

set OfficeDesktop_License=
set OfficeAccess_License=
set OfficeExcel_License=
set OfficeOutlook_License=
set OfficePowerPoint_License=
set OfficePublisher_License=
set OfficeWord_License=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows Thin PC 附加功能模块
::-------------------------------------------------------------------------------------------
:IntThinPcPkgs

if "%IsDialogsEnabled%" equ "Yes" (
	cls
	echo.===============================================================================
	echo.                MSMG 工具箱 - 集成 Windows Thin PC 附加功能
	echo.===============================================================================
	echo.
	echo.
	echo.
	echo.                              警         告
	echo.                              =============
	echo.
	echo.  在集成语言包或任何 Windows 功能之前，请不要集成任何更新。如果在集成任何
	echo.  更新、语言/功能之前集成了包含语言/功能相关资源的任何更新 ^(包括修补常规
	echo.  分发版本 [GDR]、零日修补程序 [ZDP] 或服务包 [SP] ^) ，将不会应用在更新中
	echo.  包含的特定更改，你必须重新集成更新。请始终在安装更新之前集成语言包/ 
	echo.  Windows 功能。
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  若要关闭此警告对话框，请在工具 -^> 选项菜单中选择禁用对话框
	echo.
	echo.===============================================================================
	echo.
	choice /C:YN /N /M "你想要继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :IntegrateMenu
)

setlocal

set Feature=

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 集成 Windows Thin PC 附加功能
echo.===============================================================================

:: 检查多重索引维护模式是否已启用
if "%ImageIndexNo%" equ "*" (
	echo.当多重索引维护模式已启用时，此功能不可用……
	echo.
	echo.请使用单一的索引重新选择源文件……
	goto :Stop
)

:: 检查所选择的源操作系统是否是 Windows Thin PC 操作系统
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" neq "Embedded" (
	echo.所选择的源操作系统不是 Windows Thin PC 操作系统……
	echo.
	echo.请使用 Windows Thin PC 源操作系统……
	goto :Stop
)

echo.  [A]  Microsoft .NET Framework 3.5 with Client Profile
echo.  [B]  Windows 备份和恢复
echo.  [C]  Windows 基本帮助
echo.  [D]  Windows Defender
echo.  [E]  Windows DVD Maker
echo.  [F]  Windows 传真和扫描
echo.  [G]  Windows ISO 刻录机
echo.  [H]  Windows Media Center
echo.  [I]  Windows Media Player 高级编解码器
echo.  [J]  Windows 移动中心
echo.  [K]  Windows 移动中心
echo.  [L]  Windows 照片查看器
echo.  [M]  Windows Search
echo.  [N]  Windows 语音和文本转语音美国英语包
echo.  [O]  Windows Tablet PC 支持
echo.
echo.  [1]  所有功能
echo.
echo.  [X]  返回
echo.===============================================================================
choice /C:ABCDEFGHIJKLMNo1X /N /M "请输入你的选项 ："
if errorlevel 17 goto :IntegrateMenu
if errorlevel 16 set "Feature=All"
if errorlevel 15 set "Feature=TabletPC"
if errorlevel 14 set "Feature=SpeechText"
if errorlevel 13 set "Feature=Search"
if errorlevel 12 set "Feature=PhotoViewer"
if errorlevel 11 set "Feature=ParentalControl"
if errorlevel 10 set "Feature=MobilityCenter"
if errorlevel 9  set "Feature=PremiumCodecs"
if errorlevel 8  set "Feature=MediaCenter"
if errorlevel 7  set "Feature=ISOBurner"
if errorlevel 6  set "Feature=FaxScan"
if errorlevel 5  set "Feature=DVDMaker"
if errorlevel 4  set "Feature=Defender"
if errorlevel 3  set "Feature=BasicHelp"
if errorlevel 2  set "Feature=BackupRestore"
if errorlevel 1  set "Feature=NetFx35"

cls
echo.===============================================================================
if "%Feature%" equ "NetFx35" echo.          MSMG 工具箱 - 集成 Microsoft .NET Framework 3.5 附加功能
if "%Feature%" equ "BackupRestore" echo.               MSMG 工具箱 - 集成 Windows 备份和恢复附加功能
if "%Feature%" equ "BasicHelp" echo.                MSMG 工具箱 - 集成 Windows 基本帮助附加功能
if "%Feature%" equ "Defender" echo.                MSMG 工具箱 - 集成 Windows Defender 附加功能
if "%Feature%" equ "DVDMaker" echo.                MSMG 工具箱 - 集成 Windows DVD Maker 附加功能
if "%Feature%" equ "FaxScan" echo.                MSMG 工具箱 - 集成 Windows 传真和扫描附加功能
if "%Feature%" equ "ISOBurner" echo.                MSMG 工具箱 - 集成 Windows ISO 刻录机附加功能
if "%Feature%" equ "MediaCenter" echo.               MSMG 工具箱 - 集成 Windows Media Center 附加功能
if "%Feature%" equ "PremiumCodecs" echo.           MSMG 工具箱 - 集成 Windows Media Player 高级编解码器功能
if "%Feature%" equ "MobilityCenter" echo.                  MSMG 工具箱 - 集成 Windows 移动中心附加功能
if "%Feature%" equ "ParentalControl" echo.                  MSMG 工具箱 - 集成 Windows 家长控制附加功能
if "%Feature%" equ "PhotoViewer" echo.                 MSMG 工具箱 - 集成 Windows 照片查看器附加功能
if "%Feature%" equ "Search" echo.                  MSMG 工具箱 - 集成 Windows Search 附加功能
if "%Feature%" equ "SpeechText" echo.                 MSMG 工具箱 - 集成 Windows 语音和文本附加功能
if "%Feature%" equ "TabletPC" echo.                 MSMG 工具箱 - 集成 Windows Tablet PC 附加功能
if "%Feature%" equ "All" echo.                MSMG 工具箱 - 集成 Windows Thin PC 附加功能
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 检查 Windows Thin PC 附加功能文件夹是否是空的
if not exist "%ThinPC%\*.*" (
	echo.Windows Thin PC 附加功能文件夹 ^<Packs\ThinPC^> 是空的……
	echo.
	echo.请复制 Windows Thin PC 附加功能文件到相应的文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
if "%Feature%" equ "NetFx35" echo.####正在开始集成 Microsoft .NET Framework 3.5 附加功能#########################
if "%Feature%" equ "BackupRestore" echo.####正在开始集成 Windows 备份和恢复附加功能####################################
if "%Feature%" equ "BasicHelp" echo.####正在开始集成 Windows 基本帮助附加功能######################################
if "%Feature%" equ "Defender" echo.####正在开始集成 Windows Defender 附加功能#####################################
if "%Feature%" equ "DVDMaker" echo.####正在开始集成 Windows DVD Maker 附加功能####################################
if "%Feature%" equ "FaxScan" echo.####正在开始集成 Windows 传真和扫描附加功能####################################
if "%Feature%" equ "ISOBurner" echo.####正在开始集成 Windows ISO 刻录机附加功能####################################
if "%Feature%" equ "MediaCenter" echo.####正在开始集成 Windows Media Center 附加功能#################################
if "%Feature%" equ "PremiumCodecs" echo.####正在开始集成 Windows Media Player 高级编解码器功能#########################
if "%Feature%" equ "MobilityCenter" echo.####正在开始集成 Windows 移动中心附加功能######################################
if "%Feature%" equ "ParentalControl" echo.####正在开始集成 Windows 家长控制附加功能######################################
if "%Feature%" equ "PhotoViewer" echo.####正在开始集成 Windows 照片查看器附加功能####################################
if "%Feature%" equ "Search" echo.####正在开始集成 Windows Search 附加功能#######################################
if "%Feature%" equ "SpeechText" echo.####正在开始集成 Windows 语音和文本附加功能####################################
if "%Feature%" equ "TabletPC" echo.####正在开始集成 Windows Tablet PC 附加功能####################################
if "%Feature%" equ "All" echo.####正在开始集成 Windows Thin PC 附加功能######################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%Feature%" equ "NetFx35" echo.####正在集成 Microsoft .NET Framework 3.5 附加功能#############################
if "%Feature%" equ "BackupRestore" echo.####正在集成 Windows 备份和恢复附加功能########################################
if "%Feature%" equ "BasicHelp" echo.####正在集成 Windows 基本帮助附加功能##########################################
if "%Feature%" equ "Defender" echo.####正在集成 Windows Defender 附加功能#########################################
if "%Feature%" equ "DVDMaker" echo.####正在集成 Windows DVD Maker 附加功能########################################
if "%Feature%" equ "FaxScan" echo.####正在集成 Windows 传真和扫描附加功能########################################
if "%Feature%" equ "ISOBurner" echo.####正在集成 Windows ISO 刻录机附加功能########################################
if "%Feature%" equ "MediaCenter" echo.####正在集成 Windows Media Center 附加功能#####################################
if "%Feature%" equ "PremiumCodecs" echo.####正在集成 Windows Media Player 高级编解码器功能#############################
if "%Feature%" equ "MobilityCenter" echo.####正在集成 Windows 移动中心附加功能##########################################
if "%Feature%" equ "ParentalControl" echo.####正在集成 Windows 家长控制附加功能##########################################
if "%Feature%" equ "PhotoViewer" echo.####正在集成 Windows 照片查看器附加功能########################################
if "%Feature%" equ "Search" echo.####正在集成 Windows Search 附加功能###########################################
if "%Feature%" equ "SpeechText" echo.####正在集成 Windows 语音和文本附加功能########################################
if "%Feature%" equ "TabletPC" echo.####正在集成 Windows Tablet PC 附加功能########################################
if "%Feature%" equ "All" echo.####正在集成 Windows Thin PC 附加功能##########################################
echo.-------------------------------------------------------------------------------
if "%Feature%" equ "NetFx35" (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft IIS Windows 进程激活服务包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-IIS-WAS~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 3.0 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-NetFx30~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 3.0 Client Profile 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-NetFx30Client~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 3.5 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-NetFx35~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 3.5 Client Profile 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-NetFx35Client~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
)
if "%Feature%" equ "BackupRestore" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-BackupRestore~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "BasicHelp" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-HelpEngine~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "Defender" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-AntiMalware~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "DVDMaker" (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows DVD Maker 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-DVDBurning~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows ISO 刻录机软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-IMAPIv2~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
)
if "%Feature%" equ "FaxScan" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Fax-Scan~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "ISOBurner" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-IMAPIv2~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "MediaCenter" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-MediaCenter~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "PremiumCodecs" (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player DOLBY AC3 Audio Encoder Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-DOLBY-AC3-AudioEncoder~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG2 Decoder Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG2-Decoder~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG2 Encoder Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG2-Encoder~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG2 ^& Dolby Decoder Premium Codec 软件包……..
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG2andDolbyDecoder~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG3 Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG3~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG4 Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG4~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player WMV Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-WMV~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
)
if "%Feature%" equ "MobilityCenter" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-MobilePC~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "ParentalControl" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-ParentalControl~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "PhotoViewer" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Photos-Viewer~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
if "%Feature%" equ "Search" (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 自然语言包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Natural-Language~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Search 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Search~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
)
if "%Feature%" equ "SpeechText" (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 语音和文本美国英语语言包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Speech-LP-ENG~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 语音和文本包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Speech~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
)
if "%Feature%" equ "TabletPC" call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Tablet~31bf3856ad364e35~x86~~6.1.7601.17514.cab"

if "%Feature%" equ "All" (
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft IIS Windows 进程激活服务包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-IIS-WAS~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 3.0 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-NetFx30~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 3.0 Client Profile 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-NetFx30Client~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 3.5 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-NetFx35~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft .NET Framework 3.5 Client Profile 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-NetFx35Client~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 备份和恢复软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-BackupRestore~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 基本帮助软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-HelpEngine~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Defender 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-AntiMalware~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows DVD Maker 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-DVDBurning~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 传真和扫描软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Fax-Scan~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows ISO 刻录机软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-IMAPIv2~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Center 功能……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-MediaCenter~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player DOLBY AC3 Audio Encoder Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-DOLBY-AC3-AudioEncoder~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG2 Decoder Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG2-Decoder~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG2 Encoder Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG2-Encoder~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG2 ^& Dolby Decoder Premium Codec 软件包……..
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG2andDolbyDecoder~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG3 Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG3~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player MPEG4 Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-MPEG4~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Media Player WMV Premium Codec 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-PremiumCodecs-WMV~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 移动中心功能……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-MobilePC~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 家长控制功能……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-ParentalControl~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 照片查看器功能……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Photos-Viewer~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 自然语言包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Natural-Language~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Search 软件包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Search~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 语音和文本美国英语语言包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Speech-LP-ENG~31bf3856ad364e35~x86~~6.1.7600.16385.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 语音和文本包……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Speech~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows Tablet PC 支持功能……
	echo.-------------------------------------------------------------------------------
	call :AddPackage "%InstallMount%", "%ThinPC%\WinEmb-Tablet~31bf3856ad364e35~x86~~6.1.7601.17514.cab"
)

if "%IsLogsEnabled%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	if "%Feature%" equ "NetFx35" echo.####正在生成 Microsoft .NET Framework 3.5 附加功能集成日志#####################
	if "%Feature%" equ "BackupRestore" echo.####正在生成 Windows 备份和恢复附加功能集成日志################################
	if "%Feature%" equ "BasicHelp" echo.####正在生成 Windows 基本帮助附加功能集成日志##################################
	if "%Feature%" equ "Defender" echo.####正在生成 Windows Defender 附加功能集成日志#################################
	if "%Feature%" equ "DVDMaker" echo.####正在生成 Windows DVD Maker 附加功能集成日志################################
	if "%Feature%" equ "FaxScan" echo.####正在生成 Windows 传真和扫描附加功能集成日志################################
	if "%Feature%" equ "ISOBurner" echo.####正在生成 Windows ISO 刻录机附加功能集成日志################################
	if "%Feature%" equ "MediaCenter" echo.####正在生成 Windows Media Center 附加功能集成日志#############################
	if "%Feature%" equ "PremiumCodecs" echo.####正在生成 Windows Media Player 高级编解码器集成日志#########################
	if "%Feature%" equ "MobilityCenter" echo.####正在生成 Windows 移动中心附加功能集成日志##################################
	if "%Feature%" equ "ParentalControl" echo.####正在生成 Windows 家长控制附加功能集成日志##################################
	if "%Feature%" equ "PhotoViewer" echo.####正在生成 Windows 照片查看器附加功能集成日志################################
	if "%Feature%" equ "Search" echo.###正在生成 Windows Search 附加功能集成日志###################################
	if "%Feature%" equ "SpeechText" echo.####正在生成 Windows 语音和文本附加功能集成日志################################
	if "%Feature%" equ "TabletPC" echo.####正在生成 Windows Tablet PC 附加功能集成日志################################
	if "%Feature%" equ "All" echo.####正在生成 Thin PC 附加功能集成日志##########################################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在写入 Thin PC 附加功能 ^<Logs\ThinPC.txt^> 日志文件……
	call :GetPackages "%InstallMount%", "ThinPC.txt"
	echo.
)
echo.-------------------------------------------------------------------------------
if "%Feature%" equ "NetFx35" echo.####集成 Microsoft .NET Framework 3.5 附加功能已完成###########################
if "%Feature%" equ "BackupRestore" echo.####集成 Windows 备份和恢复附加功能已完成######################################
if "%Feature%" equ "BasicHelp" echo.####集成 Windows 基本帮助附加功能已完成########################################
if "%Feature%" equ "Defender" echo.####集成 Windows Defender 附加功能已完成#######################################
if "%Feature%" equ "DVDMaker" echo.####集成 Windows DVD Maker 附加功能已完成######################################
if "%Feature%" equ "FaxScan" echo.####集成 Windows 传真和扫描附加功能已完成######################################
if "%Feature%" equ "ISOBurner" echo.####集成 Windows ISO 刻录机附加功能已完成######################################
if "%Feature%" equ "MediaCenter" echo.####集成 Windows Media Center 附加功能已完成##################################
if "%Feature%" equ "PremiumCodecs" echo.####集成 Windows Media Player 高级编解码器功能已完成###########################
if "%Feature%" equ "MobilityCenter" echo.####集成 Windows 移动中心附加功能已完成########################################
if "%Feature%" equ "ParentalControl" echo.####集成 Windows 家长控制附加功能已完成########################################
if "%Feature%" equ "PhotoViewer" echo.####集成 Windows 照片查看器附加功能已完成######################################
if "%Feature%" equ "Search" echo.####集成 Windows Search 附加功能已完成#########################################
if "%Feature%" equ "SpeechText" echo.####集成 Windows 语音和文本附加功能已完成######################################
if "%Feature%" equ "TabletPC" echo.####集成 Windows Tablet PC 附加功能已完成######################################
if "%Feature%" equ "All" echo.####集成 Windows Thin PC 附加功能已完成########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Feature=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft 诊断和恢复工具集（DaRT）7.0/8.1/10 模块
::-------------------------------------------------------------------------------------------
:IntDaRT

if "%SelectedSourceOS%" neq "w7" (
	cls
	echo.===============================================================================
	if "%SelectedSourceOS%" equ "w81" echo.                 MSMG 工具箱 - 集成 Microsoft DaRT 8.1 工具集
	if "%SelectedSourceOS%" equ "w10" echo.                  MSMG 工具箱 - 集成 Microsoft DaRT 10 工具集
	echo.===============================================================================
	echo.
	echo.
	echo.
	echo.                              警         告
	echo.                              =============
	echo.
	echo. Microsoft DaRT 8.1/10 工具集包括允许管理员或技术工作人员远程运行 DaRT 工
	echo. 具以解决终端用户计算机上的问题的功能。此外，你可以将国际标准化组织 ^(ISO^) 
	echo. 映像保存到 USB 闪存驱动器中，或者将 ISO 映像放到网络上，以便将其内容作为
	echo. 恢复分区包含在计算机的硬盘上。这些功能提供了灵活性，但也可能产生在配置 
	echo. DaRT 时应考虑到的潜在的安全风险。
	echo.
	echo.
	echo.  	
	echo.
	echo.
	echo. 若要关闭此警告对话框，请在工具 -^> 选项菜单中选择禁用对话框
	echo.
	echo.===============================================================================
	echo.
	choice /C:YN /N /M "你想要继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :MainMenu
)

setlocal

set DartType=
set PackageLanguage=
set DebugTools=

cls
echo.===============================================================================
if "%SelectedSourceOS%" equ "w7" echo.                 MSMG 工具箱 - 集成 Microsoft DaRT 7.0 工具集
if "%SelectedSourceOS%" equ "w81" echo.                 MSMG 工具箱 - 集成 Microsoft DaRT 8.1 工具集
if "%SelectedSourceOS%" equ "w10" echo.                  MSMG 工具箱 - 集成 Microsoft DaRT 10 工具集
echo.===============================================================================
echo.
:: 检查所选择的源操作系统是否是 Windows 7 Thin PC
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Embedded" (
	:: 检查源启动映像是否已选择
	if "%IsBootImageSelected%" equ "No" (
		echo.Windows 安装程序启动映像尚未选择……
		echo.
		echo.请在选择源文件时选择 Windows 安装程序启动映像……
		goto :Stop	
	)
	
	:: 设置软件包语言
	for /d %%i in (ar-SA,bg-BG,cs-CZ,da-DK,el-GR,en-GB,en-US,et-EE,fi-FI,he-IL,hr-HR,hu-HU,lt-LT,lv-LV,nb-NO,nl-NL,pl-PL,ro-RO,sk-SK,sl-SI,sr-Latn-CS,sr-Latn-RS,sv-SE,th-TH,tr-TR,uk-UA) do (
		if "%ImageDefaultLanguage%" equ "%%i" set "PackageLanguage=en-US"
	)

	if "%ImageDefaultLanguage%" equ "de-DE" set "PackageLanguage=de-DE"
	if "%ImageDefaultLanguage%" equ "es-ES" set "PackageLanguage=es-ES"
	if "%ImageDefaultLanguage%" equ "fr-FR" set "PackageLanguage=fr-FR"
	if "%ImageDefaultLanguage%" equ "it-IT" set "PackageLanguage=it-IT"
	if "%ImageDefaultLanguage%" equ "ja-JP" set "PackageLanguage=ja-JP"
	if "%ImageDefaultLanguage%" equ "ko-KR" set "PackageLanguage=ko-KR"
	if "%ImageDefaultLanguage%" equ "pt-BR" set "PackageLanguage=pt-BR"
	if "%ImageDefaultLanguage%" equ "ru-RU" set "PackageLanguage=ru-RU"
	if "%ImageDefaultLanguage%" equ "zh-CN" set "PackageLanguage=zh-CN"
	if "%ImageDefaultLanguage%" equ "zh-TW" set "PackageLanguage=zh-TW"
	if "%ImageDefaultLanguage%" equ "es-MX" set "PackageLanguage=es-ES"
	if "%ImageDefaultLanguage%" equ "fr-CA" set "PackageLanguage=fr-FR"
	if "%ImageDefaultLanguage%" equ "pt-PT" set "PackageLanguage=pt-BR"
	if "%ImageDefaultLanguage%" equ "zh-HK" set "PackageLanguage=zh-TW"	
	
	:: 设置 Microsoft DaRT 工具集包文件夹
	set "DaRT=%DaRT%\%SelectedSourceOS%"
	
	:: 检查 Microsoft DaRT 7 工具集基础包文件是否存在
	if not exist "%DaRT%\DaRT.tpk" (
		echo.Microsoft DaRT 7 工具集包文件“DaRT.tpk”没有找到……
		echo.
		echo.请复制上述文件到 ^<Packs\DaRT\%SelectedSourceOS%^> 文件夹……
		goto :Stop
	)

	:: 检查 Microsoft DaRT 7 工具集语言包文件是否存在
	if not exist "%DaRT%\DaRT_%PackageLanguage%.tpk" (
		echo.Microsoft DaRT 7 工具集包文件“DaRT_%PackageLanguage%.tpk”没有找到……
		echo.
		echo.请复制上述文件到 ^<Packs\DaRT\%SelectedSourceOS%^> 文件夹……
		goto :Stop
	)

	goto :IntDaRTBoot
)

cls
echo.===============================================================================
if "%SelectedSourceOS%" equ "w7" echo.                 MSMG 工具箱 - 集成 Microsoft DaRT 7.0 工具集
if "%SelectedSourceOS%" equ "w81" echo.                 MSMG 工具箱 - 集成 Microsoft DaRT 8.1 工具集
if "%SelectedSourceOS%" equ "w10" echo.                  MSMG 工具箱 - 集成 Microsoft DaRT 10 工具集
echo.===============================================================================
echo.
echo.  [1]  集成到 Windows 安装程序启动映像
echo.
echo.  [2]  集成到 Windows 恢复映像
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]  返回
echo.
echo.===============================================================================
echo.
choice /C:12X /N /M "请输入你的选项 ："
if errorlevel 3 goto :IntegrateMenu
if errorlevel 2 set "DartType=Recovery"
if errorlevel 1 set "DartType=Boot"

cls
echo.===============================================================================
if "%SelectedSourceOS%" equ "w7" echo.                 MSMG 工具箱 - 集成 Microsoft DaRT 7.0 工具集
if "%SelectedSourceOS%" equ "w81" echo.                 MSMG 工具箱 - 集成 Microsoft DaRT 8.1 工具集
if "%SelectedSourceOS%" equ "w10" echo.                  MSMG 工具箱 - 集成 Microsoft DaRT 10 工具集
echo.===============================================================================
echo.

:: 检查源启动映像是否已选择
if "%DartType%" equ "Boot" if "%IsBootImageSelected%" equ "No" (
	echo.Windows 安装程序启动映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 安装程序启动映像……
	goto :Stop	
)

:: 检查源恢复映像是否已选择
if "%DartType%" equ "Recovery" if "%IsRecoveryImageSelected%" equ "No" (
	echo.Windows 恢复映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 恢复映像……
	goto :Stop	
)

:: 设置软件包语言
for /d %%i in (ar-SA,bg-BG,cs-CZ,da-DK,el-GR,en-GB,en-US,et-EE,fi-FI,he-IL,hr-HR,hu-HU,lt-LT,lv-LV,nb-NO,nl-NL,pl-PL,ro-RO,sk-SK,sl-SI,sr-Latn-CS,sr-Latn-RS,sv-SE,th-TH,tr-TR,uk-UA) do (
	if "%ImageDefaultLanguage%" equ "%%i" set "PackageLanguage=en-US"
)

if "%ImageDefaultLanguage%" equ "de-DE" set "PackageLanguage=de-DE"
if "%ImageDefaultLanguage%" equ "es-ES" set "PackageLanguage=es-ES"
if "%ImageDefaultLanguage%" equ "fr-FR" set "PackageLanguage=fr-FR"
if "%ImageDefaultLanguage%" equ "it-IT" set "PackageLanguage=it-IT"
if "%ImageDefaultLanguage%" equ "ja-JP" set "PackageLanguage=ja-JP"
if "%ImageDefaultLanguage%" equ "ko-KR" set "PackageLanguage=ko-KR"
if "%ImageDefaultLanguage%" equ "pt-BR" set "PackageLanguage=pt-BR"
if "%ImageDefaultLanguage%" equ "ru-RU" set "PackageLanguage=ru-RU"
if "%ImageDefaultLanguage%" equ "zh-CN" set "PackageLanguage=zh-CN"
if "%ImageDefaultLanguage%" equ "zh-TW" set "PackageLanguage=zh-TW"
if "%ImageDefaultLanguage%" equ "es-MX" set "PackageLanguage=es-ES"
if "%ImageDefaultLanguage%" equ "fr-CA" set "PackageLanguage=fr-FR"
if "%ImageDefaultLanguage%" equ "pt-PT" set "PackageLanguage=pt-BR"
if "%ImageDefaultLanguage%" equ "zh-HK" set "PackageLanguage=zh-TW"

:: 设置 Microsoft DaRT 工具集包文件夹
set "DaRT=%DaRT%\%SelectedSourceOS%"

:: 设置 Microsoft DaRT 工具集调试工具软件包文件名称
if "%SelectedSourceOS%" equ "w10" set "DebugTools=DebugTools_%ImageVersion%.tpk"

:: 检查 Microsoft DaRT 7/8.1/10 工具集基础包文件是否存在
if not exist "%DaRT%\DaRT.tpk" (
	if "%SelectedSourceOS%" equ "w7" echo.Microsoft DaRT 7 工具集包文件“DaRT.tpk”没有找到……
	if "%SelectedSourceOS%" equ "w81" echo.Microsoft DaRT 8.1 工具集包文件“DaRT.tpk”没有找到……
	if "%SelectedSourceOS%" equ "w10" echo.Microsoft DaRT 10 工具集包文件“DaRT.tpk”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\DaRT\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft DaRT 7/8.1/10 工具语言包文件是否存在
if not exist "%DaRT%\DaRT_%PackageLanguage%.tpk" (
	if "%SelectedSourceOS%" equ "w7" echo.Microsoft DaRT 7 工具集包文件“DaRT_%PackageLanguage%.tpk”没有找到……
	if "%SelectedSourceOS%" equ "w81" echo.Microsoft DaRT 8.1 工具集包文件“DaRT_%PackageLanguage%.tpk”没有找到……
	if "%SelectedSourceOS%" equ "w10" echo.Microsoft DaRT 10 工具集包文件“DaRT_%PackageLanguage%.tpk”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\DaRT\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft DaRT 10 调试工具包文件是否存在
if "%SelectedSourceOS%" equ "w10" if not exist "%DaRT%\%DebugTools%" (
	echo.Microsoft DaRT 10 工具集包文件夹缺少以下文件……
	echo.
	echo."%DebugTools%"
	echo.
	echo.请复制上述文件到 ^<Packs\DaRT\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

if "%DartType%" equ "Boot" (
	cls
	echo.===============================================================================
	if "%SelectedSourceOS%" equ "w7" echo.     MSMG 工具箱 - 集成 Microsoft DaRT 7 工具集到 Windows 安装程序启动映像
	if "%SelectedSourceOS%" equ "w81" echo.    MSMG 工具箱 - 集成 Microsoft DaRT 8.1 工具集到 Windows 安装程序启动映像
	if "%SelectedSourceOS%" equ "w10" echo.     MSMG 工具箱 - 集成 Microsoft DaRT 10 工具集到 Windows 安装程序启动映像
	echo.===============================================================================
	echo.
	:: 获取启动映像索引体系结构
	call :GetImageArchitecture "%BootWim%", 2 >nul
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.####正在开始集成 Microsoft DaRT 7 工具集到 Windows 启动映像####################
	if "%SelectedSourceOS%" equ "w81" echo.####正在开始集成 Microsoft DaRT 8.1 工具集到 Windows 启动映像##################
	if "%SelectedSourceOS%" equ "w10" echo.####正在开始集成 Microsoft DaRT 10 工具集到 Windows 启动映像###################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.    映像文件名称             ：Boot.wim
	echo.    映像索引                 ：2
	echo.    映像体系结构             ：%ImageArchitecture%
	echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
	echo.    映像默认语言             ：%ImageDefaultLanguage%
	echo.
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.####正在集成 Microsoft DaRT 7 工具集到 Windows 启动映像########################
	if "%SelectedSourceOS%" equ "w81" echo.####正在集成 Microsoft DaRT 8.1 工具集到 Windows 启动映像######################
	if "%SelectedSourceOS%" equ "w10" echo.####正在集成 Microsoft DaRT 10 工具集到 Windows 启动映像#######################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.正在集成 Microsoft DaRT 7 工具集基础包……
	if "%SelectedSourceOS%" equ "w81" echo.正在集成 Microsoft DaRT 8.1 工具集基础包……
	if "%SelectedSourceOS%" equ "w10" echo.正在集成 Microsoft DaRT 10 工具集基础包……
	echo.-------------------------------------------------------------------------------
	if "%ImageArchitecture%" equ "x86" call :ApplyImage "%DaRT%\DaRT.tpk", 1, "%BootMount%\2"
	if "%ImageArchitecture%" equ "x64" call :ApplyImage "%DaRT%\DaRT.tpk", 2, "%BootMount%\2"
	if "%SelectedSourceOS%" equ "w10" if not exist "%BootMount%\2\Windows\System32\fmapi.dll" (
		if "%ImageIndexNo%" equ "*" copy /y "%InstallMount%\1\Windows\System32\fmapi.dll" "%BootMount%\2\Windows\System32" >nul
		if "%ImageIndexNo%" neq "*" copy /y "%InstallMount%\Windows\System32\fmapi.dll" "%BootMount%\2\Windows\System32" >nul
	)
	call :RemoveFile "%BootMount%\2\Windows\System32\winpeshl.ini"
	echo.[LaunchApps]>>"%BootMount%\2\Windows\System32\winpeshl.ini"
	echo.%%windir%%\system32\wpeinit.exe>>"%BootMount%\2\Windows\System32\winpeshl.ini"
	echo.%%windir%%\system32\netstart.exe>>"%BootMount%\2\Windows\System32\winpeshl.ini"
	echo.%%systemdrive%%\setup.exe>>"%BootMount%\2\Windows\System32\winpeshl.ini"
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.正在集成 Microsoft DaRT 7 工具集 [%PackageLanguage%] 语言包……
	if "%SelectedSourceOS%" equ "w81" echo.正在集成 Microsoft DaRT 8.1 工具集 [%PackageLanguage%] 语言包……
	if "%SelectedSourceOS%" equ "w10" echo.正在集成 Microsoft DaRT 10 工具集 [%PackageLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	if "%ImageArchitecture%" equ "x86" call :ApplyImage "%DaRT%\DaRT_%PackageLanguage%.tpk", 1, "%BootMount%\2"
	if "%ImageArchitecture%" equ "x64" call :ApplyImage "%DaRT%\DaRT_%PackageLanguage%.tpk", 2, "%BootMount%\2"
	if "%SelectedSourceOS%" equ "w10" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft DaRT 10 调试工具软件包……
		echo.-------------------------------------------------------------------------------
		if "%ImageArchitecture%" equ "x86" call :ApplyImage "%DaRT%\%DebugTools%", 1, "%BootMount%\2"
		if "%ImageArchitecture%" equ "x64" call :ApplyImage "%DaRT%\%DebugTools%", 2, "%BootMount%\2"
	)
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.####集成 Microsoft DaRT 7 工具集到 Windows 启动映像已完成######################
	if "%SelectedSourceOS%" equ "w81" echo.####集成 Microsoft DaRT 8.1 工具集到 Windows 启动映像已完成####################
	if "%SelectedSourceOS%" equ "w10" echo.####集成 Microsoft DaRT 10 工具集到 Windows 启动映像已完成#####################
	echo.-------------------------------------------------------------------------------
)

if "%DartType%" equ "Recovery" (
	cls
	echo.===============================================================================
	if "%SelectedSourceOS%" equ "w7" echo.         MSMG 工具箱 - 集成 Microsoft DaRT 7 工具集到 Windows 恢复映像
	if "%SelectedSourceOS%" equ "w81" echo.        MSMG 工具箱 - 集成 Microsoft DaRT 8.1 工具集到 Windows 恢复映像
	if "%SelectedSourceOS%" equ "w10" echo.        MSMG 工具箱 - 集成 Microsoft DaRT 10 工具集到 Windows 恢复映像
	echo.===============================================================================
	echo.
	:: 获取恢复映像索引体系结构
	if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallMount%\1\%WinReWim%", 1 >nul
	if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallMount%\%WinReWim%", 1 >nul	
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.####正在开始集成 Microsoft DaRT 7 工具集到 Windows 恢复映像####################
	if "%SelectedSourceOS%" equ "w81" echo.####正在开始集成 Microsoft DaRT 8.1 工具集到 Windows 恢复映像##################
	if "%SelectedSourceOS%" equ "w10" echo.####正在开始集成 Microsoft DaRT 10 工具集到 Windows 恢复映像###################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.    映像文件名称             ：WinRE.wim
	echo.    映像索引                 ：1
	echo.    映像体系结构             ：%ImageArchitecture%
	echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
	echo.    映像默认语言             ：%ImageDefaultLanguage%
	echo.
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.####正在集成 Microsoft DaRT 7 工具集到 Windows 恢复映像########################
	if "%SelectedSourceOS%" equ "w81" echo.####正在集成 Microsoft DaRT 8.1 工具集到 Windows 恢复映像######################
	if "%SelectedSourceOS%" equ "w10" echo.####正在集成 Microsoft DaRT 10 工具集到 Windows 恢复映像#######################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.正在集成 Microsoft DaRT 7 工具集基础包……
	if "%SelectedSourceOS%" equ "w81" echo.正在集成 Microsoft DaRT 8.1 工具集基础包……
	if "%SelectedSourceOS%" equ "w10" echo.正在集成 Microsoft DaRT 10 工具集基础包……
	echo.-------------------------------------------------------------------------------
	if "%ImageArchitecture%" equ "x86" call :ApplyImage "%DaRT%\DaRT.tpk", 1, "%WinReMount%"
	if "%ImageArchitecture%" equ "x64" call :ApplyImage "%DaRT%\DaRT.tpk", 2, "%WinReMount%"
	if "%SelectedSourceOS%" equ "w10" if not exist "%WinReMount%\Windows\System32\fmapi.dll" (
		if "%ImageIndexNo%" equ "*" copy /y "%InstallMount%\1\Windows\System32\fmapi.dll" "%WinReMount%\Windows\System32" >nul
		if "%ImageIndexNo%" neq "*" copy /y "%InstallMount%\Windows\System32\fmapi.dll" "%WinReMount%\Windows\System32" >nul
	)
	call :RemoveFile "%WinReMount%\Windows\System32\winpeshl.ini"
	echo.[LaunchApps]>>"%WinReMount%\Windows\System32\winpeshl.ini"
	echo.%%windir%%\system32\wpeinit.exe>>"%WinReMount%\Windows\System32\winpeshl.ini"
	echo.%%windir%%\system32\netstart.exe>>"%WinReMount%\Windows\System32\winpeshl.ini"
	echo.%%systemdrive%%\sources\recovery\recenv.exe>>"%WinReMount%\Windows\System32\winpeshl.ini"
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.正在集成 Microsoft DaRT 7 工具集 [%PackageLanguage%] 语言包……
	if "%SelectedSourceOS%" equ "w81" echo.正在集成 Microsoft DaRT 8.1 工具集 [%PackageLanguage%] 语言包……
	if "%SelectedSourceOS%" equ "w10" echo.正在集成 Microsoft DaRT 10 工具集 [%PackageLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	if "%ImageArchitecture%" equ "x86" call :ApplyImage "%DaRT%\DaRT_%PackageLanguage%.tpk", 1, "%WinReMount%"
	if "%ImageArchitecture%" equ "x64" call :ApplyImage "%DaRT%\DaRT_%PackageLanguage%.tpk", 2, "%WinReMount%"
	if "%SelectedSourceOS%" equ "w10" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft DaRT 10 调试工具软件包……
		echo.-------------------------------------------------------------------------------
		if "%ImageArchitecture%" equ "x86" call :ApplyImage "%DaRT%\%DebugTools%", 1, "%WinReMount%"
		if "%ImageArchitecture%" equ "x64" call :ApplyImage "%DaRT%\%DebugTools%", 2, "%WinReMount%"
	)	
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w7" echo.####集成 Microsoft DaRT 7 工具集到 Windows 恢复映像已完成######################
	if "%SelectedSourceOS%" equ "w81" echo.####集成 Microsoft DaRT 8.1 工具集到 Windows 恢复映像已完成####################
	if "%SelectedSourceOS%" equ "w10" echo.####集成 Microsoft DaRT 10 工具集到 Windows 恢复映像已完成#####################
	echo.-------------------------------------------------------------------------------
)

:Stop
echo.
echo.===============================================================================
echo.
pause

set DaRT=
set DartType=
set PackageLanguage=
set DebugTools=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft DirectX 9.0c 模块
::-------------------------------------------------------------------------------------------
:IntDirectX9c

setlocal

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 集成 Microsoft DirectX 9.0c
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 检查 Microsoft DirectX 9.0c 包文件是否存在
if not exist "%DirectX9c%\DirectX9c.tpk" (
	echo.Microsoft DirectX 9.0c 包文件“DirectX9c.tpk”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\DirectX9c^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft DirectX 9.0c 包文件是否存在
if not exist "%DirectX9c%\DirectX9c_%ImageArchitecture%.reg" (
	echo.Microsoft DirectX 9.0c 包文件“DirectX9c_%ImageArchitecture%.reg”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\DirectX9c^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft DirectX 9.0c########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft DirectX 9.0c############################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		if "%ImageArchitecture%" equ "x86" call :ApplyImage "%DirectX9c%\DirectX9c.tpk", 1, "%InstallMount%\%%i"
		if "%ImageArchitecture%" equ "x64" call :ApplyImage "%DirectX9c%\DirectX9c.tpk", 2, "%InstallMount%\%%i"
		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Microsoft DirectX 9.0c 注册表设置#################################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"	
		echo.正在将注册表设置合并到映像注册表……
		call :ImportRegistry2Image "%DirectX9c%\DirectX9c_%ImageArchitecture%.reg"		
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
	)
) else (
	if "%ImageArchitecture%" equ "x86" call :ApplyImage "%DirectX9c%\DirectX9c.tpk", 1, "%InstallMount%"
	if "%ImageArchitecture%" equ "x64" call :ApplyImage "%DirectX9c%\DirectX9c.tpk", 2, "%InstallMount%"
	echo.-------------------------------------------------------------------------------
	echo.####正在合并 Microsoft DirectX 9.0c 注册表设置#################################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"
	echo.正在将注册表设置合并到映像注册表……
	call :ImportRegistry2Image "%DirectX9c%\DirectX9c_%ImageArchitecture%.reg"	
	echo.正在卸载映像注册表……
	call :UnMountImageRegistry
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft DirectX 9.0c 已完成#########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft 游戏模块
::-------------------------------------------------------------------------------------------
:IntGames

setlocal

set Game=
set PackageLanguage=

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 集成 Microsoft 游戏
echo.===============================================================================

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 检查所选择的源操作系统是否是 Windows 7 客户端版本
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" if "%ImageEdition%" neq "HomePremium" if "%ImageEdition%" neq "HomePremiumN" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "Ultimate" if "%ImageEdition%" neq "UltimateN" (
	cls
	echo.===============================================================================
	echo.                    MSMG 工具箱 - 集成 Microsoft 游戏菜单
	echo.===============================================================================
	echo.
	echo.  [1]  Chess Titans
	echo.
	echo.  [2]  Mahjong Titans
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [A]  所有游戏
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	choice /C:12AX /N /M "请输入你的选项 ："
	if errorlevel 4 goto :IntFeatures
	if errorlevel 3 set "Game=W7Games"
	if errorlevel 2 set "Game=MahjongTitans"
	if errorlevel 1 set "Game=ChessTitans"
)

:: 检查所选择的源操作系统是否不是 Windows 7 客户端版本
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" neq "Client" (
	cls
	echo.===============================================================================
	echo.                    MSMG 工具箱 - 集成 Microsoft 游戏菜单
	echo.===============================================================================
	echo.
	echo.  [1]  Chess Titans
	echo.  [2]  空当接龙
	echo.  [3]  红心大战
	echo.  [4]  Mahjong Titans
	echo.  [5]  扫雷
	echo.  [6]  Purble Place
	echo.  [7]  纸牌
	echo.  [8]  蜘蛛纸牌
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [A]  所有游戏
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	choice /C:12345678AX /N /M "请输入你的选项 ："
	if errorlevel 10 goto :IntFeatures
	if errorlevel 9 set "Game=W7Games"
	if errorlevel 8 set "Game=SpiderSolitaire"
	if errorlevel 7 set "Game=Solitaire"
	if errorlevel 6 set "Game=PurblePlace"
	if errorlevel 5 set "Game=Minesweeper"
	if errorlevel 4 set "Game=MahjongTitans"
	if errorlevel 3 set "Game=Hearts"
	if errorlevel 2 set "Game=FreeCell"
	if errorlevel 1 set "Game=ChessTitans"
)

:: 检查所选择的源操作系统是否不是 Windows 7
if "%SelectedSourceOS%" neq "w7" (
	cls
	echo.===============================================================================
	echo.                    MSMG 工具箱 - 集成 Microsoft 游戏菜单
	echo.===============================================================================
	echo.
	echo.  [1]  Chess Titans
	echo.  [2]  空当接龙
	echo.  [3]  红心大战
	echo.  [4]  Mahjong Titans
	echo.  [5]  扫雷
	echo.  [6]  Purble Place
	echo.  [7]  纸牌
	echo.  [8]  蜘蛛纸牌
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [A]  所有游戏
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:12345678AX /N /M "请输入你的选项 ："
	if errorlevel 10 goto :IntFeatures
	if errorlevel 9 set "Game=W7Games"
	if errorlevel 8 set "Game=SpiderSolitaire"
	if errorlevel 7 set "Game=Solitaire"
	if errorlevel 6 set "Game=PurblePlace"
	if errorlevel 5 set "Game=Minesweeper"
	if errorlevel 4 set "Game=MahjongTitans"
	if errorlevel 3 set "Game=Hearts"
	if errorlevel 2 set "Game=FreeCell"
	if errorlevel 1 set "Game=ChessTitans"
)

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 集成 Microsoft 游戏
echo.===============================================================================
echo.
:: 检查 Microsoft 游戏包文件是否存在
if not exist "%Games%\Games_%ImageArchitecture%.tpk" (
	echo.Microsoft 游戏包文件“Games_%ImageArchitecture%.tpk”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if not exist "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk" (
	echo.Microsoft 游戏包文件“Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "W7Games" if not exist "%Games%\W7Games.reg" (
	echo.Microsoft 游戏包文件“W7Games.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "ChessTitans" if not exist "%Games%\ChessTitans.reg" (
	echo.Microsoft 游戏包文件“ChessTitans.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "FreeCell" if not exist "%Games%\FreeCell.reg" (
	echo.Microsoft 游戏包文件“FreeCell.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "Hearts" if not exist "%Games%\Hearts.reg" (
	echo.Microsoft 游戏包文件“Hearts.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "MahjongTitans" if not exist "%Games%\MahjongTitans.reg" (
	echo.Microsoft 游戏包文件“MahjongTitans.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "Minesweeper" if not exist "%Games%\Minesweeper.reg" (
	echo.Microsoft 游戏包文件“Minesweeper.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "PurblePlace" if not exist "%Games%\PurblePlace.reg" (
	echo.Microsoft 游戏包文件“PurblePlace.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "Solitaire" if not exist "%Games%\Solitaire.reg" (
	echo.Microsoft 游戏包文件“Solitaire.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)

:: 检查 Microsoft 游戏包文件是否存在
if "%Game%" equ "SpiderSolitaire" if not exist "%Games%\SpiderSolitaire.reg" (
	echo.Microsoft 游戏包文件“SpiderSolitaire.reg”没有找到……
	echo.                      
	echo.请复制上述文件到 ^<Packs\Games^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft 游戏################################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft 游戏####################################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 1, "%InstallMount%\%%i"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 1, "%InstallMount%\%%i"

		if "%Game%" equ "ChessTitans" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Chess Titans 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 2, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Chess Titans 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
		)
		
		if "%Game%" equ "FreeCell" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 空当接龙游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 3, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 空当接龙游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 3, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
		)
		
		if "%Game%" equ "Hearts" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 红心大战游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 4, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 红心大战游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 4, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
		)
		
		if "%Game%" equ "MahjongTitans" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Mahjong Titans 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 5, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Mahjong Titans 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 5, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
		)
		
		if "%Game%" equ "Minesweeper" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 扫雷游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 6, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 扫雷游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 6, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
		)
		
		if "%Game%" equ "PurblePlace" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Purble Place 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 7, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Purble Place 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 7, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
		)
		
		if "%Game%" equ "Solitaire" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 纸牌游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 8, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 纸牌游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 8, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
		)
		
		if "%Game%" equ "SpiderSolitaire" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 蜘蛛纸牌游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 9, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 蜘蛛纸牌游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 9, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
		)

		if "%Game%" equ "W7Games" if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" if "%ImageEdition%" neq "HomePremium" if "%ImageEdition%" neq "HomePremiumN" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "Ultimate" if "%ImageEdition%" neq "UltimateN" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Chess Titans 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 2, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Chess Titans 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Mahjong Titans 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 5, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Mahjong Titans 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 5, "%InstallMount%\%%i"
		)

		if "%Game%" equ "W7Games" if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" neq "Client" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Chess Titans 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 2, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Chess Titans 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 空当接龙游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 3, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 空当接龙游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 3, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 红心大战游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 4, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 红心大战游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 4, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Mahjong Titans 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 5, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Mahjong Titans 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 5, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 扫雷游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 6, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 扫雷游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 6, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Purble Place 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 7, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Purble Place 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 7, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 纸牌游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 8, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 纸牌游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 8, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 蜘蛛纸牌游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 9, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 蜘蛛纸牌游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 9, "%InstallMount%\%%i"
		)

		if "%Game%" equ "W7Games" if "%SelectedSourceOS%" neq "w7" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Chess Titans 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 2, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Chess Titans 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 空当接龙游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 3, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 空当接龙游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 3, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 红心大战游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 4, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 红心大战游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 4, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Mahjong Titans 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 5, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Mahjong Titans 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 5, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 扫雷游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 6, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 扫雷游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 6, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Purble Place 游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 7, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Purble Place 游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 7, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 纸牌游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 8, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 纸牌游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 8, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 蜘蛛纸牌游戏基础包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 9, "%InstallMount%\%%i"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 蜘蛛纸牌游戏 [%ImageDefaultLanguage%] 语言包……
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 9, "%InstallMount%\%%i"
		)
		
		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Microsoft 游戏注册表项############################################
		echo.-------------------------------------------------------------------------------
		echo.	
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"	

		echo.正在将注册表设置合并到映像注册表……
		if "%Game%" equ "ChessTitans" call :ImportRegistry2Image "%Games%\ChessTitans.reg"
		if "%Game%" equ "FreeCell" call :ImportRegistry2Image "%Games%\FreeCell.reg"
		if "%Game%" equ "Hearts" call :ImportRegistry2Image "%Games%\Hearts.reg"
		if "%Game%" equ "MahjongTitans" call :ImportRegistry2Image "%Games%\MahjongTitans.reg"
		if "%Game%" equ "Minesweeper" call :ImportRegistry2Image "%Games%\Minesweeper.reg"
		if "%Game%" equ "PurblePlace" call :ImportRegistry2Image "%Games%\PurblePlace.reg"
		if "%Game%" equ "Solitaire" call :ImportRegistry2Image "%Games%\Solitaire.reg"
		if "%Game%" equ "SpiderSolitaire" call :ImportRegistry2Image "%Games%\SpiderSolitaire.reg"
		if "%Game%" equ "W7Games" call :ImportRegistry2Image "%Games%\W7Games.reg"

		echo.正在卸载映像注册表……
		call :UnMountImageRegistry

		:: 删除非 Windows Media Center 相关游戏的快捷方式
		if /i not exist "%InstallMount%\%%i\Windows\ehome" (
			for %%z in (Chess, FreeCell, Hearts, Mahjong, Minesweeper, Purble Place, Solitaire, SpiderSolitaire) do (
				if /i exist "%InstallMount%\%%i\Program Files\Microsoft Games\%%z" (
					cd "%InstallMount%\%%i\Program Files\Microsoft Games\%%z" >nul
					if /i exist desktop.ini (
						attrib -h -s -a desktop.ini
						del /f /q desktop.ini >nul
					)
					cd "%ROOT%" >nul
					call :RemoveFile "%InstallMount%\%%i\Program Files\Microsoft Games\%%z\*MCE.*"
				)
			)
		)
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft 游戏基础包……
	echo.-------------------------------------------------------------------------------
	call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 1, "%InstallMount%"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft 游戏 [%ImageDefaultLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 1, "%InstallMount%"

	if "%Game%" equ "ChessTitans" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Chess Titans 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 2, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Chess Titans 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%"
	)
	
	if "%Game%" equ "FreeCell" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 空当接龙游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 3, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 空当接龙游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 3, "%InstallMount%"
	)
	
	if "%Game%" equ "Hearts" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 红心大战游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 4, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 红心大战游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 4, "%InstallMount%"
	)
	
	if "%Game%" equ "MahjongTitans" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Mahjong Titans 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 5, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Mahjong Titans 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 5, "%InstallMount%"
	)
	
	if "%Game%" equ "Minesweeper" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 扫雷游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 6, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 扫雷游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 6, "%InstallMount%"
	)
	
	if "%Game%" equ "PurblePlace" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Purble Place 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 7, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Purble Place 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 7, "%InstallMount%"
	)
	
	if "%Game%" equ "Solitaire" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 纸牌游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 8, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 纸牌游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 8, "%InstallMount%"
	)
	
	if "%Game%" equ "SpiderSolitaire" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 蜘蛛纸牌游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 9, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 蜘蛛纸牌游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 9, "%InstallMount%"
	)

	if "%Game%" equ "W7Games" if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" if "%ImageEdition%" neq "HomePremium" if "%ImageEdition%" neq "HomePremiumN" if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "ProfessionalN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "Ultimate" if "%ImageEdition%" neq "UltimateN" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Chess Titans 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 2, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Chess Titans 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Mahjong Titans 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 5, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Mahjong Titans 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 5, "%InstallMount%"
	)

	if "%Game%" equ "W7Games" if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" neq "Client" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Chess Titans 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 2, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Chess Titans 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 空当接龙游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 3, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 空当接龙游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 3, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 红心大战游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 4, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 红心大战游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 4, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Mahjong Titans 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 5, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Mahjong Titans 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 5, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 扫雷游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 6, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 扫雷游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 6, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Purble Place 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 7, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Purble Place 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 7, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 纸牌游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 8, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 纸牌游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 8, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 蜘蛛纸牌游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 9, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 蜘蛛纸牌游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 9, "%InstallMount%"
	)

	if "%Game%" equ "W7Games" if "%SelectedSourceOS%" neq "w7" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Chess Titans 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 2, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Chess Titans 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 2, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 空当接龙游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 3, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 空当接龙游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 3, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 红心大战游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 4, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 红心大战游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 4, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Mahjong Titans 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 5, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Mahjong Titans 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 5, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 扫雷游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 6, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 扫雷游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 6, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Purble Place 游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 7, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Purble Place 游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 7, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 纸牌游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 8, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 纸牌游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 8, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 蜘蛛纸牌游戏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%.tpk", 9, "%InstallMount%"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft 蜘蛛纸牌游戏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Games%\Games_%ImageArchitecture%_%ImageDefaultLanguage%.tpk", 9, "%InstallMount%"
	)
	
	echo.-------------------------------------------------------------------------------
	echo.####正在合并 Microsoft 游戏注册表项############################################
	echo.-------------------------------------------------------------------------------
	echo.	
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"	

	echo.正在将注册表设置合并到映像注册表……
	if "%Game%" equ "ChessTitans" call :ImportRegistry2Image "%Games%\ChessTitans.reg"
	if "%Game%" equ "FreeCell" call :ImportRegistry2Image "%Games%\FreeCell.reg"
	if "%Game%" equ "Hearts" call :ImportRegistry2Image "%Games%\Hearts.reg"
	if "%Game%" equ "MahjongTitans" call :ImportRegistry2Image "%Games%\MahjongTitans.reg"
	if "%Game%" equ "Minesweeper" call :ImportRegistry2Image "%Games%\Minesweeper.reg"
	if "%Game%" equ "PurblePlace" call :ImportRegistry2Image "%Games%\PurblePlace.reg"
	if "%Game%" equ "Solitaire" call :ImportRegistry2Image "%Games%\Solitaire.reg"
	if "%Game%" equ "SpiderSolitaire" call :ImportRegistry2Image "%Games%\SpiderSolitaire.reg"
	if "%Game%" equ "W7Games" call :ImportRegistry2Image "%Games%\W7Games.reg"

	echo.正在卸载映像注册表……
	call :UnMountImageRegistry

	:: 删除非 Windows Media Center 相关游戏的快捷方式
	if /i not exist "%InstallMount%\Windows\ehome" (
		for %%z in (Chess, FreeCell, Hearts, Mahjong, Minesweeper, Purble Place, Solitaire, SpiderSolitaire) do (
			if /i exist "%InstallMount%\Program Files\Microsoft Games\%%z" (
				cd "%InstallMount%\Program Files\Microsoft Games\%%z" >nul
				if /i exist desktop.ini (
					attrib -h -s -a desktop.ini
					del /f /q desktop.ini >nul
				)
				cd "%ROOT%" >nul
				call :RemoveFile "%InstallMount%\Program Files\Microsoft Games\%%z\*MCE.*"
			)
		)
	)
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft 游戏已完成##################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Game=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 边栏模块
::-------------------------------------------------------------------------------------------
:IntSidebar

setlocal

set PackageIndex=

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 集成 Windows 边栏
echo.===============================================================================
echo.
:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包索引
if "%ImageArchitecture%" equ "x86" set "PackageIndex=1"
if "%ImageArchitecture%" equ "x64" set "PackageIndex=2"

:: 检查 Windows 边栏包文件是否存在
if not exist "%Sidebar%\Sidebar.tpk" (
	echo.Windows 边栏包文件“Sidebar.tpk”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\Sidebar^> 文件夹……
	goto :Stop
)

:: 检查 Windows 边栏包文件是否存在
if not exist "%Sidebar%\Sidebar_%ImageDefaultLanguage%.tpk" (
	echo.Windows 边栏包文件“Sidebar_%ImageDefaultLanguage%.tpk”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\Sidebar^> 文件夹……
	goto :Stop
)

:: 检查 Windows 边栏包文件是否存在
if not exist "%Sidebar%\Sidebar_%ImageArchitecture%.reg" (
	echo.Windows 边栏包文件“Sidebar_%ImageArchitecture%.reg”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\Sidebar^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 边栏##################################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 边栏######################################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 边栏基础包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Sidebar%\Sidebar.tpk", %PackageIndex%, "%InstallMount%\%%i"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 边栏 [%ImageDefaultLanguage%] 语言包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%Sidebar%\Sidebar_%ImageDefaultLanguage%.tpk", %PackageIndex%, "%InstallMount%\%%i"

		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Windows 边栏注册表设置############################################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"
		echo.正在取得映像注册表所有权……
		echo.正在将注册表设置合并到映像注册表……
		call :ImportRegistry2Image "%Sidebar%\Sidebar_%ImageArchitecture%.reg"
		call :ImportRegistry2Image "%Sidebar%\3rdPartyGadgets_%ImageArchitecture%.reg"
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
		echo.

		:: 如果源版本不是 Media Center 版则删除 Microsoft 边栏 Media Center 文件
		if /i not exist "%InstallMount%\%%i\Windows\ehome" call :RemoveFolder "%InstallMount%\%%i\Program Files\Windows Sidebar\Gadgets\MediaCenter.Gadget"
	)
) else (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 边栏基础包……
	echo.-------------------------------------------------------------------------------
	call :ApplyImage "%Sidebar%\Sidebar.tpk", %PackageIndex%, "%InstallMount%"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 Windows 边栏 [%ImageDefaultLanguage%] 语言包……
	echo.-------------------------------------------------------------------------------
	call :ApplyImage "%Sidebar%\Sidebar_%ImageDefaultLanguage%.tpk", %PackageIndex%, "%InstallMount%"
	
	echo.-------------------------------------------------------------------------------
	echo.####正在合并 Windows 边栏注册表设置############################################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"	
	echo.正在将注册表设置合并到映像注册表……
	call :ImportRegistry2Image "%Sidebar%\Sidebar_%ImageArchitecture%.reg"
	call :ImportRegistry2Image "%Sidebar%\3rdPartyGadgets_%ImageArchitecture%.reg"
	echo.正在卸载映像注册表……
	call :UnMountImageRegistry

	:: 如果源版本不是 Media Center 版则删除 Microsoft 边栏 Media Center 文件
	call :RemoveFolder "%InstallMount%\Program Files\Windows Sidebar\Gadgets\MediaCenter.Gadget"
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 边栏已完成####################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set PackageIndex=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft Visual C++ Runtime 模块
::-------------------------------------------------------------------------------------------
:IntVCRuntime

setlocal

set PackageIndex=

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 集成 Microsoft Visual C++ Runtime
echo.===============================================================================
echo.

:: 设置 Microsoft Visual C++ Runtime 包文件夹路径
set "VCRuntime=%VCRuntime%\%SelectedSourceOS%"

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包索引
if "%ImageArchitecture%" equ "x86" set "PackageIndex=1"
if "%ImageArchitecture%" equ "x64" set "PackageIndex=2"

:: 检查 Microsoft Visual C++ Runtime 包文件是否存在
if not exist "%VCRuntime%\VC.tpk" (
	echo.Microsoft Visual C++ Runtime 包文件“VC.tpk”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\VCRuntime\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

if "%SelectedSourceOS%" equ "w7" if not exist "%VCRuntime%\Windows6.1-KB3118401-%ImageArchitecture%.cab" (
	echo.Microsoft Visual C++ Runtime 包文件“Windows6.1-KB3118401-%ImageArchitecture%.cab”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\VCRuntime\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

if "%SelectedSourceOS%" equ "w81" if not exist "%VCRuntime%\Windows8.1-KB3118401-%ImageArchitecture%.cab" (
	echo.Microsoft Visual C++ Runtime 包文件“Windows8.1-KB3118401-%ImageArchitecture%.cab”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\VCRuntime\%SelectedSourceOS%^> 文件夹……
	goto :Stop
)

for %%i in (Certificates, VC_2005, VC_2008, VC_2010, VC_2012, VC_2013, VC_2019, VC_Legacy) do (
	if not exist "%VCRuntime%\%%i_%ImageArchitecture%.reg" (
		echo.Microsoft Visual C++ Runtime 包文件“%%i_%ImageArchitecture%.reg”没有找到……
		echo.
		echo.请复制上述文件到 ^<Packs\VCRuntime\%SelectedSourceOS%^> 文件夹……
		goto :Stop
	)
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft Visual C++ Runtime##################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft Visual C++ Runtime######################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		:: 获取映像索引信息
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		if "%SelectedSourceOS%" neq "w10" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Visual C++ 先决条件更新包……
			echo.-------------------------------------------------------------------------------
			if "%SelectedSourceOS%" equ "w7" call :AddPackage "%InstallMount%\%%i", "%VCRuntime%\Windows6.1-KB3118401-%ImageArchitecture%.cab"
			if "%SelectedSourceOS%" equ "w81" call :AddPackage "%InstallMount%\%%i", "%VCRuntime%\Windows8.1-KB3118401-%ImageArchitecture%.cab"
		)

		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Visual C++ Runtime 软件包……
		echo.-------------------------------------------------------------------------------
		call :ApplyImage "%VCRuntime%\VC.tpk", %PackageIndex%, "%InstallMount%\%%i"
		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Microsoft Visual C++ Runtime 注册表设置###########################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"
		echo.正在将注册表设置合并到映像注册表……

		for %%i in (Certificates, VC_2005, VC_2008, VC_2010, VC_2012, VC_2013, VC_2019, VC_Legacy) do (
			call :ImportRegistry2Image "%VCRuntime%\%%i_%ImageArchitecture%.reg"
		)

		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
	)
) else (
	echo.
	if "%SelectedSourceOS%" neq "w10" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Microsoft Visual C++ 先决条件更新包……
		echo.-------------------------------------------------------------------------------
		if "%SelectedSourceOS%" equ "w7" call :AddPackage "%InstallMount%", "%VCRuntime%\Windows6.1-KB3118401-%ImageArchitecture%.cab"
		if "%SelectedSourceOS%" equ "w81" call :AddPackage "%InstallMount%", "%VCRuntime%\Windows8.1-KB3118401-%ImageArchitecture%.cab"
	)

	echo.-------------------------------------------------------------------------------
	echo.正在集成 Microsoft Visual C++ Runtime 软件包……
	echo.-------------------------------------------------------------------------------
	call :ApplyImage "%VCRuntime%\VC.tpk", %PackageIndex%, "%InstallMount%"
	echo.-------------------------------------------------------------------------------
	echo.####正在合并 Microsoft Visual C++ Runtime 注册表设置###########################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"
	echo.正在将注册表设置合并到映像注册表……

	for %%i in (Certificates, VC_2005, VC_2008, VC_2010, VC_2012, VC_2013, VC_2019, VC_Legacy) do (
		call :ImportRegistry2Image "%VCRuntime%\%%i_%ImageArchitecture%.reg"
	)

	echo.正在卸载映像注册表……
	call :UnMountImageRegistry
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft Visual C++ Runtime 已完成###################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set VCRuntime=
set PackageIndex=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 更新菜单模块
::-------------------------------------------------------------------------------------------
:IntUpdatesMenu

if "%IsDialogsEnabled%" equ "Yes" (
	cls
	echo.===============================================================================
	echo.                      MSMG 工具箱 - 集成 Windows 更新
	echo.===============================================================================
	echo.
	echo.
	echo.
	echo.                              警         告
	echo.                              =============
	echo.
	echo.  在集成语言包或任何 Windows 功能之前，请不要集成任何更新。如果在集成任何
	echo.  更新、语言/功能之前集成了包含语言/功能相关资源的任何更新 ^(包括修补常规
	echo.  分发版本 [GDR]、零日修补程序 [ZDP] 或服务包 [SP] ^) ，将不会应用在更新中
	echo.  包含的特定更改，你必须重新集成更新。请始终在安装更新之前集成语言包/ 
	echo.  Windows 功能。
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  若要关闭此警告对话框，请在工具 -^> 选项菜单中选择禁用对话框
	echo.
	echo.===============================================================================
	echo.
	choice /C:YN /N /M "你想要继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :IntegrateMenu
)

cls
echo.===============================================================================
echo.                   MSMG 工具箱 - 集成 Windows 更新菜单
echo.===============================================================================
echo.
echo.  [1]   集成 Windows 更新
echo.
echo.  [2]   集成 WHD 更新包
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.

choice /C:12X /N /M "请输入你的选项 ："
if errorlevel 3 goto :IntegrateMenu
if errorlevel 2 goto :IntWHDUpdatesMenu
if errorlevel 1 call :IntUpdates WUpdates

:IntWHDUpdatesMenu
cls
echo.===============================================================================
echo.                     MSMG 工具箱 - 集成 WHD 更新包菜单
echo.===============================================================================
echo.
if "%SelectedSourceOS%" equ "w7" (
	echo.  [1]   集成 WHD 更新包 ^(含 Service Pack 2^)
	echo.
	echo.  [2]   集成 WHD 更新包 ^(不含 Service Pack 2^)
	echo.
	echo.  [3]   集成 Windows 安装程序媒介更新
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
)

if "%SelectedSourceOS%" equ "w81" (
	echo.  [1]   集成 WHD 基线更新
	echo.
	echo.  [2]   集成 WHD 常规更新
	echo.
	echo.  [3]   集成 WHD 热修复更新
	echo.
	echo.  [4]   集成 WHD 安全更新
	echo.
	echo.  [5]   集成 WHD 附加更新
	echo.
	echo.  [6]   集成 Windows 安装程序媒介更新
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
)

if "%SelectedSourceOS%" equ "w10" (
	echo.  [1]   集成 WHD 常规更新
	echo.
	echo.  [2]   集成 Windows 安装程序媒介更新
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
)

if "%SelectedSourceOS%" equ "w7" (
	choice /C:123X /N /M "请输入你的选项 ："
	if errorlevel 4 goto :IntegrateMenu
	if errorlevel 3 goto :IntWindowsSetupMediaUpdates
	if errorlevel 2 (
		set IsW7SP1CRUSelected=0
		goto :IntW7WHDUpdatesMenu
	)
	if errorlevel 1 (
		set IsW7SP1CRUSelected=1
		goto :IntW7WHDUpdatesMenu
	)
)

if "%SelectedSourceOS%" equ "w81" (
	choice /C:123456X /N /M "请输入你的选项 ："
	if errorlevel 7 goto :IntegrateMenu
	if errorlevel 6 goto :IntWindowsSetupMediaUpdates
	if errorlevel 5 goto :IntWHDAdditionalMenu
	if errorlevel 4 call :IntUpdates Security
	if errorlevel 3 call :IntUpdates Hotfix
	if errorlevel 2 call :IntUpdates General
	if errorlevel 1 goto :IntWHDBaselineMenu
)

if "%SelectedSourceOS%" equ "w10" (
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :IntegrateMenu
	if errorlevel 2 goto :IntWindowsSetupMediaUpdates
	if errorlevel 1 goto :IntWHDBaselineMenu
)

:IntW7WHDUpdatesMenu
if "%IsDialogsEnabled%" equ "Yes" if "%IsW7SP1CRUSelected%" equ "1" (
	cls
	echo.===============================================================================
	echo.               MSMG 工具箱 - 集成 WHD 更新 ^(含 Service Pack 2^)
	echo.===============================================================================
	echo.      ## 适用于 Windows 7 SP1 的便捷汇总更新，又被称为 Service Pack 2 ##
	echo.
	echo.KB3125574 是一个全面的汇总更新，包含几乎所有在 Windows 7 SP1 发布之后所发布
	echo.的修复程序，时间截止到 2016 年 4 月。
	echo.
	echo.如果你打算集成以下所列的任何功能包，请将它们 * 优先 * ^(在 KB3125574 之前^)
	echo.集成，以便汇总更新可以在以后集成其更新的组件：
	echo.
	echo.DCA2.0、AD LDS、VirtualPC、WorkFolders、在 WHD 附加中找到的 Server Essentials 
	echo.连接器额外更新部分。
	echo.
	echo.此更新旨在于简化 Windows 7 的更新过程，但它完全是可选的，请注意，出于尽职调查
	echo.的目的，它确实包含一些遥测更新组件 ^(3068708、3075249^)。
	echo.因此，如果你不想使用遥测更新，则应选择集成 WHD 更新菜单中的“集成 WHD 更新 ^(
	echo.不含 Service Pack 2^) ”选项。
	echo.
	echo.你还可以在阻止这些遥测效果的同时集成汇总。
	echo.请参考此主题以获取详细信息：http://forums.mydigitallife.info/threads/68131
	echo.
	echo.
	echo.===============================================================================
	pause
)
cls
echo.===============================================================================
echo.                       MSMG 工具箱 - 集成 WHD 更新菜单
echo.===============================================================================
echo.
if "%SelectedSourceOS%" equ "w7" (
	echo.  [1]   集成 WHD 附加更新
	echo.
	echo.  [2]   集成 WHD 额外更新
	echo.
	echo.  [3]   集成 WHD 常规更新
	echo.
	echo.  [4]   集成 WHD 热修复更新
	echo.
	echo.  [5]   集成 WHD 安全更新
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
)

if "%SelectedSourceOS%" equ "w7" (
	choice /C:12345X /N /M "请输入你的选项 ："
	if errorlevel 6 goto :IntegrateMenu
	if errorlevel 5 call :IntUpdates "Security"
	if errorlevel 4 call :IntUpdates "Hotfix"
	if errorlevel 3 call :IntUpdates "General"
	if errorlevel 2 goto :IntWHDExtraMenu
	if errorlevel 1 goto :IntWHDAdditionalMenu
)

:IntWHDBaselineMenu
cls

echo.===============================================================================
if "%SelectedSourceOS%" equ "w81" echo.                     MSMG 工具箱 - 集成 WHD 基线更新菜单
if "%SelectedSourceOS%" equ "w10" echo.                     MSMG 工具箱 - 集成 WHD 常规更新菜单
echo.===============================================================================
echo.
echo.  [1]   集成到 Windows 安装程序启动映像
echo.
echo.  [2]   集成到 Windows 安装程序安装映像
echo.
echo.  [3]   集成到 Windows 安装程序安装和恢复映像
echo.
echo.  [4]   集成到 Windows 安装程序启动、安装和恢复映像
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:1234X /N /M "请输入你的选项 ："
if errorlevel 5 goto :IntUpdatesMenu
if errorlevel 4 goto :IntWHDBaseBootInstallRecovery
if errorlevel 3 goto :IntWHDBaseInstallRecovery
if errorlevel 2 goto :IntWHDBaseInstall
if errorlevel 1 goto :IntWHDBaseBoot

:IntWHDAdditionalMenu
cls

echo.===============================================================================
echo.                     MSMG 工具箱 - 集成 WHD 附加更新菜单
echo.===============================================================================
echo.
if "%SelectedSourceOS%" equ "w7" (
	echo.  [1]   集成 Windows 激活技术 ^(WAT^)
	echo.
	echo.  [2]   集成 Windows 10 升级先决条件
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
)

if "%SelectedSourceOS%" equ "w81" (
	echo.  [1]   集成 Microsoft .NET Framework 3.5 更新
	echo.
	echo.  [2]   集成 Windows 10 升级先决条件
	echo.
	echo.  [3]   集成 Windows PE 更新
	echo.
	echo.  [4]   集成 Windows Update Satisfy Updates
	echo.
	echo.
	echo.
	echo.
)

echo.
echo.	
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
if "%SelectedSourceOS%" equ "w7" (
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :IntW7WHDUpdatesMenu
	if errorlevel 2 call :IntUpdates "Windows10"
	if errorlevel 1 call :IntUpdates "WAT"
)

if "%SelectedSourceOS%" equ "w81" (
	choice /C:1234X /N /M "请输入你的选项 ："
	if errorlevel 5 goto :IntWHDUpdatesMenu
	if errorlevel 4 call :IntUpdates "WUSatisfy"
	if errorlevel 3 call :IntUpdates "WinPE"
	if errorlevel 2 call :IntUpdates "Windows10"
	if errorlevel 1 call :IntUpdates "NET35"
)

:IntWHDExtraMenu
cls

echo.===============================================================================
echo.                     MSMG 工具箱 - 集成 WHD 额外更新菜单
echo.===============================================================================

if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" (
	echo.  [1]   Active Directory 轻型目录服务 ^(ADLDS^)
	echo.
	echo.  [2]   文件管理 API
	echo.
	echo.  [3]   Microsoft Virtual PC
	echo.
	echo.  [4]   Windows 功能更新
	echo.
	echo.  [5]   适用于域环境的同步代理^(工作文件夹^)
	echo.	
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  
	echo.  [X]   返回
	echo.===============================================================================
	echo.
)

if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" (
	echo.
	echo.  [1]   Active Directory 轻型目录服务 ^(ADLDS^)
	echo.
	echo.  [2]   文件管理 API
	echo.
	echo.  [3]   Microsoft Virtual PC
	echo.	
	echo.  [4]   适用于域环境的同步代理^(工作文件夹^)
	echo.	
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.	
	echo.===============================================================================
	echo.
)

if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" (
	choice /C:12345X /N /M "请输入你的选项 ："
	if errorlevel 6 goto :IntW7WHDUpdatesMenu
	if errorlevel 5 call :IntUpdates "WorkFolders"
	if errorlevel 4 call :IntUpdates "Features"	
	if errorlevel 3 call :IntUpdates "VirtualPC"
	if errorlevel 2 call :IntUpdates "FMApi"
	if errorlevel 1 call :IntUpdates "ADLDS"
)

if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" (
	choice /C:1234X /N /M "请输入你的选项 ："
	if errorlevel 5 goto :IntW7WHDUpdatesMenu
	if errorlevel 4 call :IntUpdates "WorkFolders"
	if errorlevel 3 call :IntUpdates "VirtualPC"
	if errorlevel 2 call :IntUpdates "FMApi"
	if errorlevel 1 call :IntUpdates "ADLDS"
)

::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 WHD 基线更新到 Windows 安装程序启动映像模块
::-------------------------------------------------------------------------------------------
:IntWHDBaseBoot

setlocal

cls
echo.===============================================================================
if "%SelectedSourceOS%" equ "w81" echo.          MSMG 工具箱 - 集成 WHD 基线更新到 Windows 安装程序启动映像
if "%SelectedSourceOS%" equ "w10" echo.          MSMG 工具箱 - 集成 WHD 常规更新到 Windows 安装程序启动映像
echo.===============================================================================
echo.
if "%IsBootImageSelected%" equ "No" (
	echo.Windows 安装程序启动映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 安装程序启动映像……
	goto :Stop	
)

:: 获取启动映像索引体系结构
call :GetImageArchitecture "%BootWim%", 1 >nul

:: 设置 WHD 基线更新文件夹路径
if "%SelectedSourceOS%" equ "w81" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%\Baseline"
if "%SelectedSourceOS%" equ "w10" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查 WHD 基线更新文件夹是否是空的
:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	if not exist "%Updates%\RTM\*.msu" if not exist "%Updates%\RTM\*.cab" (
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline\RTM^> 是空的……
	)
	if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
		echo.
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline^> 是空的……
	)
	echo.
	echo.请复制 WHD 基线更新到相应文件夹……
	goto :Stop
)

:: Windows 8.1 Post-RTM
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" neq "16384" (
	if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline^> 是空的……
		echo.
		echo.请复制 WHD 基线更新到相应文件夹……
		goto :Stop
	)
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" if not exist "%Updates%\Cumulative\*.msu" if not exist "%Updates%\Cumulative\*.cab" (
	echo.WHD 常规更新文件夹 ^<WHD\w10\%ImageArchitecture%\Cumulative^> 是空的……
	echo.
	echo.请复制 WHD 常规更新到相应文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在开始集成 WHD 基线更新到 Windows 安装程序启动映像#######################
if "%SelectedSourceOS%" equ "w10" echo.####正在开始集成 WHD 常规更新到 Windows 安装程序启动映像#######################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Boot.wim
echo.    映像索引                 ：1, 2
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在处理 WHD 基线更新包####################################################
if "%SelectedSourceOS%" equ "w10" echo.####正在处理 WHD 常规更新包####################################################
echo.-------------------------------------------------------------------------------
echo.
:: 创建 WHD 基线更新临时文件夹
if "%SelectedSourceOS%" equ "w81" echo.正在创建 WHD 基线更新临时文件夹……
if "%SelectedSourceOS%" equ "w10" echo.正在创建 WHD 常规更新临时文件夹……
call :RemoveFolder "%Temp%\Updates"
call :CreateFolder "%Temp%\Updates"
echo.

:: 从 .MSU 包文件解压 .CAB 文件到 CAB 临时文件夹
echo.正在解压 .CAB 软件包文件到临时文件夹……

:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul	
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update Refresh（IR4 内部版本 ：6.3.9600.17056）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" (
	for /d %%j in (ServicingStack, Cumulative) do (
		if exist "%Updates%\%%j\*%ImageArchitecture%*.msu" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.msu" -F:*.cab "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\wsusscan.cab"
			expand -R "%Temp%\Updates\%%j\*.cab" -F:* "%Temp%\Updates\%%j" >nul
			if "%%j" equ "Cumulative" if exist "%Temp%\Updates\%%j\Cab_*.cab" expand -R "%Temp%\Updates\%%j\Cab_*.cab" -F:* "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\*.cab"
		)
		if exist "%Updates%\%%j\*%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.cab" -F:* "%Temp%\Updates\%%j" >nul
			if "%%j" equ "Cumulative" if exist "%Temp%\Updates\%%j\Cab_*.cab" expand -R "%Temp%\Updates\%%j\Cab_*.cab" -F:* "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\*.cab"
		)
	)
	
	for /d %%j in (WinPE, SetupMedia) do (	
		if exist "%Updates%\%%j\*%ImageArchitecture%*.msu" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.msu" -F:*.cab "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\wsusscan.cab"		
		)
	
		if exist "%Updates%\%%j\*%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%%j"
			%XCopy% "%Updates%\%%j\*%ImageArchitecture%*.cab" "%Temp%\Updates\%%j" >nul
		)
	)	
)
echo.
echo.解压 .CAB 软件包文件到临时文件夹已完成……
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在集成 WHD 基线更新到 Windows 安装程序启动映像###########################
if "%SelectedSourceOS%" equ "w10" echo.####正在集成 WHD 常规更新到 Windows 安装程序启动映像###########################
echo.-------------------------------------------------------------------------------
echo.
:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	for /l %%i in (1, 1, 2) do (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线更新 ^(KB2919355^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	)
)

:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
	for /l %%i in (1, 1, 2) do (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"    
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
	)
)

:: Windows 8.1 with Update（IR4 内部版本 ：6.3.9600.17056）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
	for /l %%i in (1, 1, 2) do (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"    
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
	)
)

:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
	for /l %%i in (1, 1, 2) do (
		if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到启动映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"		
	)
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" (
	for /l %%i in (1, 1, 2) do (
		if exist "%Temp%\Updates\ServicingStack\Update.mum" (
			if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1507 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%BootMount%\%%i"
				if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%BootMount%\%%i"
				call :MountImageRegistry "%BootMount%\%%i"
				call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
				call :UnMountImageRegistry
			)
			if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1607 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%BootMount%\%%i"
				call :MountImageRegistry "%BootMount%\%%i"
				call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
				call :UnMountImageRegistry
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 服务堆栈更新到启动映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\ServicingStack"
		)
		if exist "%Temp%\Updates\Cumulative\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 累积更新到启动映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Cumulative"
		)
	)
	if exist "%Temp%\Updates\WinPE\*.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 WinPE 更新到启动映像
		echo.---------------------------------[索引 ：2]------------------------------------
		call :AddPackage "%BootMount%\2", "%Temp%\Updates\WinPE"
	)
	if exist "%Temp%\Updates\SetupMedia\*.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 安装程序媒介更新
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在解压 Windows 10 安装程序媒介更新到 ^<DVD^> 文件夹……
		expand -R "%Temp%\Updates\SetupMedia\*.cab" -F:* "%DVD%\sources" >nul
		cd /d "%DVD%\sources\" >nul
		for /d %%i in (ar-SA,bg-BG,cs-CZ,da-DK,de-DE,el-GR,en-GB,en-US,es-ES,es-MX,et-EE,fi-FI,fr-CA,fr-FR,he-IL,hr-HR,hu-HU,it-IT,ja-JP,ko-KR,lt-LT,lv-LV,nb-NO,nl-NL,pl-PL,pt-BR,pt-PT,ro-RO,ru-RU,sk-SK,sl-SI,sr-Latn-RS,sv-SE,th-TH,tr-TR,uk-UA,zh-CN,zh-HK,zh-TW) do (
			if "%ImageDefaultLanguage%" neq "%%i" rd /q /s "%DVD%\sources\%%i" >nul 2>&1
		)
		cd /d "%ROOT%\" >nul
		echo.
	)
)

if "%IsLogsEnabled%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w81" echo.####正在生成 WHD 基线更新集成日志文件##########################################
	if "%SelectedSourceOS%" equ "w10" echo.####正在生成 WHD 常规更新集成日志文件##########################################
	echo.-------------------------------------------------------------------------------
	echo.
	for /l %%k in (1, 1, 2) do (
		if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [Boot.wim，索引 ：%%k] 集成日志……
		if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [Boot.wim，索引 ：%%k] 集成日志……
		call :GetPackages "%BootMount%\%%k", "Boot-%%k.txt"
		echo.
	)
)
echo.-------------------------------------------------------------------------------
echo.####正在清理临时文件和文件夹###################################################
echo.-------------------------------------------------------------------------------
echo.
if "%SelectedSourceOS%" equ "w81" echo.正在清理 WHD 基线更新临时文件夹……
if "%SelectedSourceOS%" equ "w10" echo.正在清理 WHD 基线更新临时文件夹……
call :RemoveFolder "%Temp%\Updates"
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####集成 WHD 基线更新到 Windows 安装启动映像已完成#############################
if "%SelectedSourceOS%" equ "w10" echo.####集成 WHD 一般更新到 Windows 安装启动映像已完成#############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Updates=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 WHD 基线更新到 Windows 安装程序安装映像模块
::-------------------------------------------------------------------------------------------
:IntWHDBaseInstall

setlocal

cls
echo.===============================================================================
if "%SelectedSourceOS%" equ "w81" echo.          MSMG 工具箱 - 集成 WHD 基线更新到 Windows 安装程序安装映像
if "%SelectedSourceOS%" equ "w10" echo.          MSMG 工具箱 - 集成 WHD 常规更新到 Windows 安装程序安装映像
echo.===============================================================================
echo.
:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 设置 WHD 基线更新文件夹路径
if "%SelectedSourceOS%" equ "w81" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%\Baseline"
if "%SelectedSourceOS%" equ "w10" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查 WHD 基线更新文件夹是否是空的
:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	if not exist "%Updates%\RTM\*.msu" if not exist "%Updates%\RTM\*.cab" (
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline\RTM^> 是空的……
	)
	if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
		echo.
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline^> 是空的……
	)
	echo.
	echo.请复制 WHD 基线更新到相应文件夹……
	goto :Stop
)

:: Windows 8.1 Post-RTM
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" neq "16384" (
	if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline^> 是空的……
		echo.
		echo.请复制 WHD 基线更新到相应文件夹……
		goto :Stop
	)
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" if not exist "%Updates%\Cumulative\*.msu" if not exist "%Updates%\Cumulative\*.cab" (
	echo.WHD 常规更新文件夹 ^<WHD\w10\%ImageArchitecture%\Cumulative^> 是空的……
	echo.
	echo.请复制 WHD 常规更新到相应文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.#############正在开始集成 WHD 基线更新到 Windows 安装程序安装映像##############
if "%SelectedSourceOS%" equ "w10" echo.#############正在开始集成 WHD 常规更新到 Windows 安装程序安装映像##############
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" neq "*" if not "%ImageCount%" gtr "9" echo.    映像索引范围             ：%ImageIndexNo%
if "%ImageIndexNo%" neq "*" if "%ImageCount%" gtr "9" echo.    映像索引范围             ：%ImageIndexNo%
if "%ImageIndexNo%" equ "*" if not "%ImageCount%" gtr "9" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" equ "*" if "%ImageCount%" gtr "9" echo.    映像索引范围             ：1-%ImageCount%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在处理 WHD 基线更新包####################################################
if "%SelectedSourceOS%" equ "w10" echo.####正在处理 WHD 常规更新包####################################################
echo.-------------------------------------------------------------------------------
echo.
:: 创建 WHD 基线更新临时文件夹
if "%SelectedSourceOS%" equ "w81" echo.正在创建 WHD 基线更新临时文件夹……
if "%SelectedSourceOS%" equ "w10" echo.正在创建 WHD 常规更新临时文件夹……
call :RemoveFolder "%Temp%\Updates"
call :CreateFolder "%Temp%\Updates"
echo.

:: 从 .MSU 包文件解压 .CAB 文件到 CAB 临时文件夹
echo.正在解压 .CAB 软件包文件到临时文件夹……

:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul	
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update Refresh（IR4 内部版本 ：6.3.9600.17056）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" (
	for /d %%j in (ServicingStack, Cumulative, Enablement, FlashPlayer) do (
		if exist "%Updates%\%%j\*%ImageArchitecture%*.msu" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.msu" -F:*.cab "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\wsusscan.cab"
			expand -R "%Temp%\Updates\%%j\*.cab" -F:* "%Temp%\Updates\%%j" >nul
			if "%%j" equ "Cumulative" if exist "%Temp%\Updates\%%j\Cab_*.cab" expand -R "%Temp%\Updates\%%j\Cab_*.cab" -F:* "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\*.cab"
		)
		if exist "%Updates%\%%j\*%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.cab" -F:* "%Temp%\Updates\%%j" >nul
			if "%%j" equ "Cumulative" if exist "%Temp%\Updates\%%j\Cab_*.cab" expand -R "%Temp%\Updates\%%j\Cab_*.cab" -F:* "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\*.cab"
		)
	)
	
	for /d %%j in (Dynamic, NetCumulative, WinPE) do (	
		if exist "%Updates%\%%j\*%ImageArchitecture%*.msu" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.msu" -F:*.cab "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\wsusscan.cab"		
		)
	
		if exist "%Updates%\%%j\*%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%%j"
			%XCopy% "%Updates%\%%j\*%ImageArchitecture%*.cab" "%Temp%\Updates\%%j" >nul
		)
	)	
)
echo.
echo.解压 .CAB 软件包文件到临时文件夹已完成……
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在集成 WHD 基线更新到 Windows 安装程序安装映像###########################
if "%SelectedSourceOS%" equ "w10" echo.####正在集成 WHD 常规更新到 Windows 安装程序安装映像###########################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
		if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线更新 ^(KB2919355^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update（IR4 内部版本 ：6.3.9600.17056）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"			
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
			if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
		)

		:: Windows 10
		if "%SelectedSourceOS%" equ "w10" (
			:: 合并注册表修复以启用集成到 Windows 10 非-LTSB 版的 Windows 10 LTSB 2015 更新。
			if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版（N）的 Windows 10 教育版/企业版更新。
			if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版/LTSB 2016 更新的 Windows 10 教育版/企业版/LTSB 2016 更新。
			if "%ImageBuild%" equ "14393" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 专业工作站版的 Windows 更新。
			if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstation" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)
			
			:: 合并注册表修复以启用集成到 Windows 10 专业工作站版‘N’的 Windows 更新。
			if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstationN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)
		
			if exist "%Temp%\Updates\ServicingStack\Update.mum" (
				if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
					echo.-------------------------------------------------------------------------------
					echo.正在应用 Windows 10 v1507 累积更新集成修复
					echo.-------------------------------------------------------------------------------
					if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%InstallMount%\%%i"
					if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%InstallMount%\%%i"
					call :MountImageRegistry "%InstallMount%\%%i"
					call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
					call :UnMountImageRegistry
				)
				if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
					echo.-------------------------------------------------------------------------------
					echo.正在应用 Windows 10 v1607 累积更新集成修复
					echo.-------------------------------------------------------------------------------
					call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%InstallMount%\%%i"
					call :MountImageRegistry "%InstallMount%\%%i"
					call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
					call :UnMountImageRegistry
				)
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 服务堆栈更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\ServicingStack"
			)
			if exist "%Temp%\Updates\Dynamic\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 动态更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Dynamic"
			)
			if exist "%Temp%\Updates\FlashPlayer\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Adobe Flash Player 安全更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\FlashPlayer"
			)
			if exist "%Temp%\Updates\NetCumulative\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 .NET 累积更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\NetCumulative"
			)
			if exist "%Temp%\Updates\Cumulative\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 累积更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Cumulative"		
			)
			if exist "%Temp%\Updates\Enablement\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 功能启用包到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Enablement"		
			)
		)
	)
) else (
	:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
	if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线更新 ^(KB2919355^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"		
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update（IR4 内部版本 ：6.3.9600.17056）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"			
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
		if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	)

	:: Windows 10
	if "%SelectedSourceOS%" equ "w10" (
		:: 合并注册表修复以启用集成到 Windows 10 非-LTSB 版的 Windows 10 LTSB 2015 更新。
		if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)
			
		:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版（N）的 Windows 10 教育版/企业版更新。
		if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)

		:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版/LTSB 2016 更新的 Windows 10 教育版/企业版/LTSB 2016 更新。
		if "%ImageBuild%" equ "14393" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)

		:: 合并注册表修复以启用集成到 Windows 10 专业工作站版的 Windows 更新。
		if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstation" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)		
		
		:: 合并注册表修复以启用集成到 Windows 10 专业工作站版‘N’的 Windows 更新。
		if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstationN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)
				
		if exist "%Temp%\Updates\ServicingStack\Update.mum" (
			if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1507 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%InstallMount%"
				if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%InstallMount%"
				call :MountImageRegistry "%InstallMount%"
				call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
				call :UnMountImageRegistry
			)
			if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1607 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%InstallMount%"
				call :MountImageRegistry "%InstallMount%"
				call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
				call :UnMountImageRegistry
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 服务堆栈更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\ServicingStack"
		)
		if exist "%Temp%\Updates\Dynamic\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 动态更新到安装映像
				echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
				call :AddPackage "%InstallMount%", "%Temp%\Updates\Dynamic"
		)
		if exist "%Temp%\Updates\FlashPlayer\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Adobe Flash Player 安全更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\FlashPlayer"
		)
		if exist "%Temp%\Updates\NetCumulative\*.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 .NET 累积更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\NetCumulative"
		)
		if exist "%Temp%\Updates\Cumulative\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 累积更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Cumulative"
		)
		if exist "%Temp%\Updates\Enablement\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 功能启用包到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Enablement"		
		)
	)
)

if "%IsLogsEnabled%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w81" echo.####正在生成 WHD 基线更新集成日志文件##########################################
	if "%SelectedSourceOS%" equ "w10" echo.####正在生成 WHD 常规更新集成日志文件##########################################
	echo.-------------------------------------------------------------------------------
	echo.
	if "%ImageIndexNo%" equ "*" (
		if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [Install.wim，索引 ：1-%ImageCount%] 集成日志……
		if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [Install.wim，索引 ：1-%ImageCount%] 集成日志……
		for /L %%k in (1, 1, %ImageCount%) do (
			call :GetPackages "%InstallMount%\%%k", "Install-%%k.txt"
		)
	) else (
		if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [Install.wim，索引 ：%ImageIndexNo%] 集成日志……
		if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [Install.wim，索引 ：%ImageIndexNo%] 集成日志……
		call :GetPackages "%InstallMount%", "Install.txt"
	)
	echo.
)

echo.-------------------------------------------------------------------------------
echo.####正在清理临时文件和文件夹###################################################
echo.-------------------------------------------------------------------------------
echo.
if "%SelectedSourceOS%" equ "w81" echo.正在清理 WHD 基线更新临时文件夹……
if "%SelectedSourceOS%" equ "w10" echo.正在清理 WHD 基线更新临时文件夹……
call :RemoveFolder "%Temp%\Updates"
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.##############集成 WHD 基线更新到 Windows 安装程序安装映像已完成###############
if "%SelectedSourceOS%" equ "w10" echo.##############集成 WHD 常规更新到 Windows 安装程序安装映像已完成###############
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set PackageArchitecture=
set Updates=

endlocal

:: 读取已更新的映像信息
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageIndexNo%" equ "*" (
		call :GetImageIndexInfo "%InstallWim%", 1 >nul
		call :MountImageRegistry "%InstallMount%\1"
		for /f "tokens=3 delims= " %%z in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do (set /a ImageServicePackBuild=%%z)
		call :UnMountImageRegistry
	) else (
		call :GetImageIndexInfo "%InstallWim%", %ImageIndexNo% >nul
		call :MountImageRegistry "%InstallMount%"
		for /f "tokens=3 delims= " %%z in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do (set /a ImageServicePackBuild=%%z)
		call :UnMountImageRegistry
	)
)

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 WHD 基线更新到 Windows 安装程序安装和恢复映像模块
::-------------------------------------------------------------------------------------------
:IntWHDBaseInstallRecovery

setlocal

cls
echo.===============================================================================
if "%SelectedSourceOS%" equ "w81" echo.                       MSMG 工具箱 - 集成 WHD 基线更新
if "%SelectedSourceOS%" equ "w10" echo.                       MSMG 工具箱 - 集成 WHD 常规更新
echo.                      到 Windows 安装程序安装和恢复映像
echo.===============================================================================
echo.
if "%IsRecoveryImageSelected%" equ "No" (
	echo.Windows 恢复映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 恢复映像……
	goto :Stop	
)

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 设置 WHD 基线更新文件夹路径
if "%SelectedSourceOS%" equ "w81" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%\Baseline"
if "%SelectedSourceOS%" equ "w10" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查 WHD 基线更新文件夹是否是空的
:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	if not exist "%Updates%\RTM\*.msu" if not exist "%Updates%\RTM\*.cab" (
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline\RTM^> 是空的……
	)
	if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
		echo.
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline^> 是空的……
	)
	echo.
	echo.请复制 WHD 基线更新到相应文件夹……
	goto :Stop
)

:: Windows 8.1 Post-RTM
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" neq "16384" (
	if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline^> 是空的……
		echo.
		echo.请复制 WHD 基线更新到相应文件夹……
		goto :Stop
	)
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" if not exist "%Updates%\Cumulative\*.msu" if not exist "%Updates%\Cumulative\*.cab" (
	echo.WHD 常规更新文件夹 ^<WHD\w10\%ImageArchitecture%\Cumulative^> 是空的……
	echo.
	echo.请复制 WHD 常规更新到相应文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.##########################正在开始集成 WHD 基线更新############################
if "%SelectedSourceOS%" equ "w10" echo.##########################正在开始集成 WHD 常规更新############################
echo.####################到 Windows 安装程序安装和恢复映像##########################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim        ^|  WinRE.wim
if "%ImageIndexNo%" neq "*" if not "%ImageCount%" gtr "9" echo.    映像索引范围             ：%ImageIndexNo%                  ^|      1
if "%ImageIndexNo%" neq "*" if "%ImageCount%" gtr "9" echo.    映像索引范围             ：%ImageIndexNo%                  ^|      1
if "%ImageIndexNo%" equ "*" if not "%ImageCount%" gtr "9" echo.    映像索引范围             ：1-%ImageCount%                ^|     1
if "%ImageIndexNo%" equ "*" if "%ImageCount%" gtr "9" echo.    映像索引范围             ：1-%ImageCount%             ^|      1
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在处理 WHD 基线更新包####################################################
if "%SelectedSourceOS%" equ "w10" echo.####正在处理 WHD 常规更新包####################################################
echo.-------------------------------------------------------------------------------
echo.
:: 创建 WHD 基线更新临时文件夹
if "%SelectedSourceOS%" equ "w81" echo.正在创建 WHD 基线更新临时文件夹……
if "%SelectedSourceOS%" equ "w10" echo.正在创建 WHD 常规更新临时文件夹……
call :RemoveFolder "%Temp%\Updates"
call :CreateFolder "%Temp%\Updates"
echo.

:: 从 .MSU 包文件解压 .CAB 文件到 CAB 临时文件夹
echo.正在解压 .CAB 软件包文件到临时文件夹……

:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul	
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update Refresh（IR4 内部版本 ：6.3.9600.17056）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3014442-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" (
	for /d %%j in (ServicingStack, Cumulative, Enablement, FlashPlayer) do (
		if exist "%Updates%\%%j\*%ImageArchitecture%*.msu" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.msu" -F:*.cab "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\wsusscan.cab"
			expand -R "%Temp%\Updates\%%j\*.cab" -F:* "%Temp%\Updates\%%j" >nul
			if "%%j" equ "Cumulative" if exist "%Temp%\Updates\%%j\Cab_*.cab" expand -R "%Temp%\Updates\%%j\Cab_*.cab" -F:* "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\*.cab"
		)
		if exist "%Updates%\%%j\*%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.cab" -F:* "%Temp%\Updates\%%j" >nul
			if "%%j" equ "Cumulative" if exist "%Temp%\Updates\%%j\Cab_*.cab" expand -R "%Temp%\Updates\%%j\Cab_*.cab" -F:* "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\*.cab"
		)
	)
	
	for /d %%j in (Dynamic, NetCumulative, WinPE) do (	
		if exist "%Updates%\%%j\*%ImageArchitecture%*.msu" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.msu" -F:*.cab "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\wsusscan.cab"		
		)
	
		if exist "%Updates%\%%j\*%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%%j"
			%XCopy% "%Updates%\%%j\*%ImageArchitecture%*.cab" "%Temp%\Updates\%%j" >nul
		)
	)	
)
echo.
echo.解压 .CAB 软件包文件到临时文件夹已完成……
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在集成 WHD 基线更新到 Windows 安装程序安装映像###########################
if "%SelectedSourceOS%" equ "w10" echo.####正在集成 WHD 常规更新到 Windows 安装程序安装映像###########################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
		if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线更新 ^(KB2919355^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update（IR4 内部版本 ：6.3.9600.17056）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"			
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
			if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
		)

		:: Windows 10
		if "%SelectedSourceOS%" equ "w10" (
			:: 合并注册表修复以启用集成到 Windows 10 非-LTSB 版的 Windows 10 LTSB 2015 更新。
			if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版（N）的 Windows 10 教育版/企业版更新。
			if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版/LTSB 2016 更新的 Windows 10 教育版/企业版/LTSB 2016 更新。
			if "%ImageBuild%" equ "14393" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 专业工作站版的 Windows 更新。
			if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstation" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)
			
			:: 合并注册表修复以启用集成到 Windows 10 专业工作站版‘N’的 Windows 更新。
			if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstationN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)
		
			if exist "%Temp%\Updates\ServicingStack\Update.mum" (
				if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
					echo.-------------------------------------------------------------------------------
					echo.正在应用 Windows 10 v1507 累积更新集成修复
					echo.-------------------------------------------------------------------------------
					if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%InstallMount%\%%i"
					if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%InstallMount%\%%i"
					call :MountImageRegistry "%InstallMount%\%%i"
					call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
					call :UnMountImageRegistry
				)
				if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
					echo.-------------------------------------------------------------------------------
					echo.正在应用 Windows 10 v1607 累积更新集成修复
					echo.-------------------------------------------------------------------------------
					call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%InstallMount%\%%i"
					call :MountImageRegistry "%InstallMount%\%%i"
					call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
					call :UnMountImageRegistry
				)
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 服务堆栈更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\ServicingStack"
			)
			if exist "%Temp%\Updates\Dynamic\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 动态更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Dynamic"
			)
			if exist "%Temp%\Updates\FlashPlayer\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Adobe Flash Player 安全更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\FlashPlayer"
			)
			if exist "%Temp%\Updates\NetCumulative\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 .NET 累积更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\NetCumulative"
			)
			if exist "%Temp%\Updates\Cumulative\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 累积更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Cumulative"		
			)
			if exist "%Temp%\Updates\Enablement\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 功能启用包到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Enablement"		
			)
		)
	)
) else (
	:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
	if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线更新 ^(KB2919355^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"		
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update（IR4 内部版本 ：6.3.9600.17056）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"			
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
		if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	)

	:: Windows 10
	if "%SelectedSourceOS%" equ "w10" (
		:: 合并注册表修复以启用集成到 Windows 10 非-LTSB 版的 Windows 10 LTSB 2015 更新。
		if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)
			
		:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版（N）的 Windows 10 教育版/企业版更新。
		if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)

		:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版/LTSB 2016 更新的 Windows 10 教育版/企业版/LTSB 2016 更新。
		if "%ImageBuild%" equ "14393" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)

		:: 合并注册表修复以启用集成到 Windows 10 专业工作站版的 Windows 更新。
		if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstation" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)		
		
		:: 合并注册表修复以启用集成到 Windows 10 专业工作站版‘N’的 Windows 更新。
		if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstationN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)
				
		if exist "%Temp%\Updates\ServicingStack\Update.mum" (
			if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1507 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%InstallMount%"
				if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%InstallMount%"
				call :MountImageRegistry "%InstallMount%"
				call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
				call :UnMountImageRegistry
			)
			if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1607 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%InstallMount%"
				call :MountImageRegistry "%InstallMount%"
				call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
				call :UnMountImageRegistry
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 服务堆栈更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\ServicingStack"
		)
		if exist "%Temp%\Updates\Dynamic\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 动态更新到安装映像
				echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
				call :AddPackage "%InstallMount%", "%Temp%\Updates\Dynamic"
		)
		if exist "%Temp%\Updates\FlashPlayer\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Adobe Flash Player 安全更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\FlashPlayer"
		)
		if exist "%Temp%\Updates\NetCumulative\*.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 .NET 累积更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\NetCumulative"
		)
		if exist "%Temp%\Updates\Cumulative\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 累积更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Cumulative"
		)
		if exist "%Temp%\Updates\Enablement\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 功能启用包到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Enablement"		
		)
	)
)
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在集成 WHD 基线更新到 Windows 安装程序恢复映像###########################
if "%SelectedSourceOS%" equ "w10" echo.####正在集成 WHD 常规更新到 Windows 安装程序恢复映像###########################
echo.-------------------------------------------------------------------------------
echo.
:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线更新 ^(KB2919355^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
)

:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
)

:: Windows 8.1 with Update Refresh（IR4 内部版本 ：6.3.9600.17056）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
)

:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
	if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到恢复映像
		echo.---------------------------------[索引 ：1]------------------------------------
		call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
	)
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
)	

:: Windows 10
if "%SelectedSourceOS%" equ "w10" (
	if exist "%Temp%\Updates\ServicingStack\Update.mum" (
		if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
			echo.-------------------------------------------------------------------------------
			echo.正在应用 Windows 10 v1507 累积更新集成修复
			echo.-------------------------------------------------------------------------------
			if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%WinReMount%"
			if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%WinReMount%"
			call :MountImageRegistry "%WinReMount%"
			call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
			call :UnMountImageRegistry
		)
		if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
			echo.-------------------------------------------------------------------------------
			echo.正在应用 Windows 10 v1607 累积更新集成修复
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%WinReMount%"
			call :MountImageRegistry "%WinReMount%"
			call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
			call :UnMountImageRegistry
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 服务堆栈更新到恢复映像
		echo.---------------------------------[索引 ：1]------------------------------------
		call :AddPackage "%WinReMount%", "%Temp%\Updates\ServicingStack"
	)
	if exist "%Temp%\Updates\Cumulative\Update.mum" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 累积更新到恢复映像
		echo.---------------------------------[索引 ：1]------------------------------------
		call :AddPackage "%WinReMount%", "%Temp%\Updates\Cumulative"
	)
	if exist "%Temp%\Updates\WinPE\*.cab" (
	echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 WinPE 更新到恢复映像
		echo.---------------------------------[索引 ：1]------------------------------------
		call :AddPackage "%WinReMount%", "%Temp%\Updates\WinPE"
	)
)

if "%IsLogsEnabled%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w81" echo.####正在生成 WHD 基线更新集成日志文件##########################################
	if "%SelectedSourceOS%" equ "w10" echo.####正在生成 WHD 常规更新集成日志文件##########################################
	echo.-------------------------------------------------------------------------------
	echo.
	if "%ImageIndexNo%" equ "*" (
		if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [Install.wim，索引 ：1-%ImageCount%] 集成日志……
		if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [Install.wim，索引 ：1-%ImageCount%] 集成日志……
		for /L %%k in (1, 1, %ImageCount%) do (
			call :GetPackages "%InstallMount%\%%k", "Install-%%k.txt"
		)
	) else (
		if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [Install.wim，索引 ：%ImageIndexNo%] 集成日志……
		if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [Install.wim，索引 ：%ImageIndexNo%] 集成日志……
		call :GetPackages "%InstallMount%", "Install.txt"
	)
	echo.
	if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [WinRe.wim，索引 ：1] 集成日志……
	if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [WinRe.wim，索引 ：1] 集成日志……
	call :GetPackages "%WinReMount%", "Install_WinRE.txt"
	echo.
)

echo.-------------------------------------------------------------------------------
echo.####正在清理临时文件和文件夹###################################################
echo.-------------------------------------------------------------------------------
echo.
if "%SelectedSourceOS%" equ "w81" echo.正在清理 WHD 基线更新临时文件夹……
if "%SelectedSourceOS%" equ "w10" echo.正在清理 WHD 基线更新临时文件夹……
call :RemoveFolder "%Temp%\Updates"
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.#############################集成 WHD 基线更新#################################
if "%SelectedSourceOS%" equ "w10" echo.#############################集成 WHD 常规更新#################################
echo.##################到 Windows 安装程序安装和恢复映像已完成######################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set PackageArchitecture=
set Updates=

endlocal

:: 读取已更新的映像信息
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageIndexNo%" equ "*" (
		call :GetImageIndexInfo "%InstallWim%", 1 >nul
		call :MountImageRegistry "%InstallMount%\1"
		for /f "tokens=3 delims= " %%z in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do (set /a ImageServicePackBuild=%%z)
		call :UnMountImageRegistry
	) else (
		call :GetImageIndexInfo "%InstallWim%", %ImageIndexNo% >nul
		call :MountImageRegistry "%InstallMount%"
		for /f "tokens=3 delims= " %%z in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do (set /a ImageServicePackBuild=%%z)
		call :UnMountImageRegistry
	)
)

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 WHD 基线更新到 Windows 安装程序启动、安装和恢复映像模块
::-------------------------------------------------------------------------------------------
:IntWHDBaseBootInstallRecovery

setlocal

cls
echo.===============================================================================
if "%SelectedSourceOS%" equ "w81" echo.                       MSMG 工具箱 - 集成 WHD 基线更新
if "%SelectedSourceOS%" equ "w10" echo.                       MSMG 工具箱 - 集成 WHD 常规更新
echo.                  到 Windows 安装程序启动、安装和恢复映像
echo.===============================================================================
echo.
if "%IsBootImageSelected%" equ "No" (
	echo.Windows 安装程序启动映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 安装程序启动映像……
	goto :Stop	
)

if "%IsRecoveryImageSelected%" equ "No" (
	echo.Windows 恢复映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 恢复映像……
	goto :Stop	
)

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包的体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

:: 设置 WHD 基线更新文件夹路径
if "%SelectedSourceOS%" equ "w81" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%\Baseline"
if "%SelectedSourceOS%" equ "w10" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查 WHD 基线更新文件夹是否是空的
:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	if not exist "%Updates%\RTM\*.msu" if not exist "%Updates%\RTM\*.cab" (
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline\RTM^> 是空的……
	)
	if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
		echo.
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline^> 是空的……
	)
	echo.
	echo.请复制 WHD 基线更新到相应文件夹……
	goto :Stop
)

:: Windows 8.1 Post-RTM
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" neq "16384" (
	if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
		echo.WHD 基线更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Baseline^> 是空的……
		echo.
		echo.请复制 WHD 基线更新到相应文件夹……
		goto :Stop
	)
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" if not exist "%Updates%\Cumulative\*.msu" if not exist "%Updates%\Cumulative\*.cab" (
	echo.WHD 常规更新文件夹 ^<WHD\w10\%ImageArchitecture%\Cumulative^> 是空的……
	echo.
	echo.请复制 WHD 常规更新到相应文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.##########################正在开始集成 WHD 基线更新############################
if "%SelectedSourceOS%" equ "w10" echo.##########################正在开始集成 WHD 常规更新############################
echo.#################到 Windows 安装程序启动、安装和恢复映像#######################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Boot.wim         ^|  Install.wim   ^|  WinRE.wim
if "%ImageIndexNo%" neq "*" echo.    映像索引范围             ：1, 2             ^|      %ImageIndexNo%         ^|      1
if "%ImageIndexNo%" equ "*" if not "%ImageCount%" gtr "9" echo.    映像索引范围             ：1, 2             ^|      1-%ImageCount%       ^|      1
if "%ImageIndexNo%" equ "*" if "%ImageCount%" gtr "9" echo.    映像索引范围             ：1, 2             ^|      1-%ImageCount%     ^|      1
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在处理 WHD 基线更新包####################################################
if "%SelectedSourceOS%" equ "w10" echo.####正在处理 WHD 常规更新包####################################################
echo.-------------------------------------------------------------------------------
echo.
:: 创建 WHD 基线更新临时文件夹
if "%SelectedSourceOS%" equ "w81" echo.正在创建 WHD 基线更新临时文件夹……
if "%SelectedSourceOS%" equ "w10" echo.正在创建 WHD 常规更新临时文件夹……
call :RemoveFolder "%Temp%\Updates"
call :CreateFolder "%Temp%\Updates"
echo.

:: 从 .MSU 包文件解压 .CAB 文件到 CAB 临时文件夹
echo.正在解压 .CAB 软件包文件到临时文件夹……

:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.msu" expand "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2919355-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2932046-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2937592-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2938439-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.cab" %XCopy% "%Updates%\RTM\Windows8.1-KB2938772-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB2934018-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul	
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update Refresh（IR4 内部版本 ：6.3.9600.17056）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3000850-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3003057-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" expand "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates" >nul

	:: 从 .MSU 软件包文件中复制 .CAB 文件到 CAB 临时文件夹
	if exist "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB3021910-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
	if exist "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" %XCopy% "%Updates%\Windows8.1-KB4566425-%ImageArchitecture%*.cab" "%Temp%\Updates" >nul
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" (
	for /d %%j in (ServicingStack, Cumulative, Enablement, FlashPlayer) do (
		if exist "%Updates%\%%j\*%ImageArchitecture%*.msu" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.msu" -F:*.cab "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\wsusscan.cab"
			expand -R "%Temp%\Updates\%%j\*.cab" -F:* "%Temp%\Updates\%%j" >nul
			if "%%j" equ "Cumulative" if exist "%Temp%\Updates\%%j\Cab_*.cab" expand -R "%Temp%\Updates\%%j\Cab_*.cab" -F:* "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\*.cab"
		)
		if exist "%Updates%\%%j\*%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.cab" -F:* "%Temp%\Updates\%%j" >nul
			if "%%j" equ "Cumulative" if exist "%Temp%\Updates\%%j\Cab_*.cab" expand -R "%Temp%\Updates\%%j\Cab_*.cab" -F:* "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\*.cab"
		)
	)
	
	for /d %%j in (Dynamic, NetCumulative, SetupMedia, WinPE) do (	
		if exist "%Updates%\%%j\*%ImageArchitecture%*.msu" (
			call :CreateFolder "%Temp%\Updates\%%j"
			expand -R "%Updates%\%%j\*%ImageArchitecture%*.msu" -F:*.cab "%Temp%\Updates\%%j" >nul
			call :RemoveFile "%Temp%\Updates\%%j\wsusscan.cab"		
		)
	
		if exist "%Updates%\%%j\*%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%%j"
			%XCopy% "%Updates%\%%j\*%ImageArchitecture%*.cab" "%Temp%\Updates\%%j" >nul
		)
	)	
)
echo.
echo.解压 .CAB 软件包文件到临时文件夹已完成……
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在集成 WHD 基线更新到 Windows 安装程序启动映像###########################
if "%SelectedSourceOS%" equ "w10" echo.####正在集成 WHD 常规更新到 Windows 安装程序启动映像###########################
echo.-------------------------------------------------------------------------------
echo.
:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	for /l %%i in (1, 1, 2) do (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线更新 ^(KB2919355^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	)
)

:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
	for /l %%i in (1, 1, 2) do (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"    
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
	)
)

:: Windows 8.1 with Update（IR4 内部版本 ：6.3.9600.17056）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
	for /l %%i in (1, 1, 2) do (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"    
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
	)
)

:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
	for /l %%i in (1, 1, 2) do (
		if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到启动映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到启动映像
		echo.---------------------------------[索引 ：%%i]------------------------------------
		call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"		
	)
)

:: Windows 10
if "%SelectedSourceOS%" equ "w10" (
	for /l %%i in (1, 1, 2) do (
		if exist "%Temp%\Updates\ServicingStack\Update.mum" (
			if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1507 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%BootMount%\%%i"
				if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%BootMount%\%%i"
				call :MountImageRegistry "%BootMount%\%%i"
				call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
				call :UnMountImageRegistry
			)
			if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1607 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%BootMount%\%%i"
				call :MountImageRegistry "%BootMount%\%%i"
				call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
				call :UnMountImageRegistry
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 服务堆栈更新到启动映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\ServicingStack"
		)
		if exist "%Temp%\Updates\Cumulative\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 累积更新到启动映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%BootMount%\%%i", "%Temp%\Updates\Cumulative"
		)
	)
	if exist "%Temp%\Updates\WinPE\*.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 WinPE 更新到启动映像
		echo.---------------------------------[索引 ：2]------------------------------------
		call :AddPackage "%BootMount%\2", "%Temp%\Updates\WinPE"
	)
	if exist "%Temp%\Updates\SetupMedia\*.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 安装程序媒介更新
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在解压 Windows 10 安装程序媒介更新到 ^<DVD^> 文件夹……
		expand -R "%Temp%\Updates\SetupMedia\*.cab" -F:* "%DVD%\sources" >nul
		cd /d "%DVD%\sources\" >nul
		for /d %%i in (ar-SA,bg-BG,cs-CZ,da-DK,de-DE,el-GR,en-GB,en-US,es-ES,es-MX,et-EE,fi-FI,fr-CA,fr-FR,he-IL,hr-HR,hu-HU,it-IT,ja-JP,ko-KR,lt-LT,lv-LV,nb-NO,nl-NL,pl-PL,pt-BR,pt-PT,ro-RO,ru-RU,sk-SK,sl-SI,sr-Latn-RS,sv-SE,th-TH,tr-TR,uk-UA,zh-CN,zh-HK,zh-TW) do (
			if "%ImageDefaultLanguage%" neq "%%i" rd /q /s "%DVD%\sources\%%i" >nul 2>&1
		)
		cd /d "%ROOT%\" >nul
		echo.
	)
)
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在集成 WHD 基线更新到 Windows 安装程序安装映像###########################
if "%SelectedSourceOS%" equ "w10" echo.####正在集成 WHD 常规更新到 Windows 安装程序安装映像###########################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
		if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线更新 ^(KB2919355^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update（IR4 内部版本 ：6.3.9600.17056）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"			
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		)

		:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
		if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
			if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
		)

		:: Windows 10
		if "%SelectedSourceOS%" equ "w10" (
			:: 合并注册表修复以启用集成到 Windows 10 非-LTSB 版的 Windows 10 LTSB 2015 更新。
			if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版（N）的 Windows 10 教育版/企业版更新。
			if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版/LTSB 2016 更新的 Windows 10 教育版/企业版/LTSB 2016 更新。
			if "%ImageBuild%" equ "14393" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)

			:: 合并注册表修复以启用集成到 Windows 10 专业工作站版的 Windows 更新。
			if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstation" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)
			
			:: 合并注册表修复以启用集成到 Windows 10 专业工作站版‘N’的 Windows 更新。
			if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstationN" (
				call :MountImageRegistry "%InstallMount%\%%i"
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
				reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
				call :UnMountImageRegistry
			)
					
			if exist "%Temp%\Updates\ServicingStack\Update.mum" (
				if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
					echo.-------------------------------------------------------------------------------
					echo.正在应用 Windows 10 v1507 累积更新集成修复
					echo.-------------------------------------------------------------------------------
					if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%InstallMount%\%%i"
					if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%InstallMount%\%%i"
					call :MountImageRegistry "%InstallMount%\%%i"
					call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
					call :UnMountImageRegistry
				)
				if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
					echo.-------------------------------------------------------------------------------
					echo.正在应用 Windows 10 v1607 累积更新集成修复
					echo.-------------------------------------------------------------------------------
					call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%InstallMount%\%%i"
					call :MountImageRegistry "%InstallMount%\%%i"
					call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
					call :UnMountImageRegistry
				)
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 服务堆栈更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\ServicingStack"
			)
			if exist "%Temp%\Updates\Dynamic\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 动态更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Dynamic"
			)
			if exist "%Temp%\Updates\FlashPlayer\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Adobe Flash Player 安全更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\FlashPlayer"
			)
			if exist "%Temp%\Updates\NetCumulative\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 .NET 累积更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\NetCumulative"
			)
			if exist "%Temp%\Updates\Cumulative\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 累积更新到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Cumulative"		
			)
			if exist "%Temp%\Updates\Enablement\Update.mum" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 10 功能启用包到安装映像
				echo.---------------------------------[索引 ：%%i]------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\Enablement"		
			)
		)
	)
) else (
	:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
	if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线更新 ^(KB2919355^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"		
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update（IR4 内部版本 ：6.3.9600.17056）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"			
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3014442^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3014442-%ImageArchitecture%.cab"
	)

	:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
	if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
		if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到安装映像
		echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	)

	:: Windows 10
	if "%SelectedSourceOS%" equ "w10" (
		:: 合并注册表修复以启用集成到 Windows 10 非-LTSB 版的 Windows 10 LTSB 2015 更新。
		if "%ImageBuild%" equ "10240" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10240.16384" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)

		:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版（N）的 Windows 10 教育版/企业版更新。
		if "%ImageBuild%" equ "10586" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\th2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.10586.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)

		:: 合并注册表修复以启用集成到 Windows 10 非教育版/企业版/LTSB 2016 更新的 Windows 10 教育版/企业版/LTSB 2016 更新。
		if "%ImageBuild%" equ "14393" if "%ImageEdition%" neq "Education" if "%ImageEdition%" neq "EducationN" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "EnterpriseN" if "%ImageEdition%" neq "EnterpriseS" if "%ImageEdition%" neq "EnterpriseSN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs1.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-EnterpriseEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.14393.0" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)

		:: 合并注册表修复以启用集成到 Windows 10 专业工作站版的 Windows 更新。
		if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstation" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)		
		
		:: 合并注册表修复以启用集成到 Windows 10 专业工作站版‘N’的 Windows 更新。
		if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "ProfessionalWorkstationN" (
			call :MountImageRegistry "%InstallMount%"
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallClient" /t REG_SZ /d "DISM Package Manager Provider" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallName" /t REG_SZ /d "Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15.mum" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallLocation" /t REG_SZ /d "\\?\d:\rs2.bin.%PackageArchitecture%fre\csi\pkgs\\" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "CurrentState" /t REG_DWORD /d "112" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "SelfUpdate" /t REG_DWORD /d "0" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "Visibility" /t REG_DWORD /d "1" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeHigh" /t REG_DWORD /d "30649479" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallTimeLow" /t REG_DWORD /d "1431244152" /f >nul
			reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-ProfessionalNEdition~31bf3856ad364e35~%PackageArchitecture%~~10.0.16299.15" /v "InstallUser" /t REG_SZ /d "S-1-5-18" /f >nul
			call :UnMountImageRegistry
		)	
		
		if exist "%Temp%\Updates\ServicingStack\Update.mum" (
			if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1507 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%InstallMount%"
				if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%InstallMount%"
				call :MountImageRegistry "%InstallMount%"
				call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
				call :UnMountImageRegistry
			)
			if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
				echo.-------------------------------------------------------------------------------
				echo.正在应用 Windows 10 v1607 累积更新集成修复
				echo.-------------------------------------------------------------------------------
				call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%InstallMount%"
				call :MountImageRegistry "%InstallMount%"
				call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
				call :UnMountImageRegistry
			)
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 服务堆栈更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\ServicingStack"
		)
		if exist "%Temp%\Updates\Dynamic\*.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 动态更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Dynamic"
		)
		if exist "%Temp%\Updates\FlashPlayer\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Adobe Flash Player 安全更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\FlashPlayer"
		)
		if exist "%Temp%\Updates\NetCumulative\*.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 .NET 累积更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\NetCumulative"
		)
		if exist "%Temp%\Updates\Cumulative\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 累积更新到安装映像
			echo.---------------------------------[索引 ： %ImageIndexNo%]-----------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Cumulative"
		)
		if exist "%Temp%\Updates\Enablement\Update.mum" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 10 功能启用包到安装映像
			echo.---------------------------------[索引 ：%%i]------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\Enablement"		
		)
	)
)
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.####正在集成 WHD 基线更新到 Windows 安装程序恢复映像###########################
if "%SelectedSourceOS%" equ "w10" echo.####正在集成 WHD 常规更新到 Windows 安装程序恢复映像###########################
echo.-------------------------------------------------------------------------------
echo.
:: Windows 8.1 RTM（内部版本 ：6.3.9600.16384）
if "%SelectedSourceOS%" equ "w81" if %ImageServicePackBuild% equ 16384 (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线先决条件更新 ^(KB3021910^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线更新 ^(KB2919355^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2919355-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2932046^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2932046-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2937592^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2937592-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2938439^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2938439-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2938772^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2938772-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
)

:: Windows 8.1 with Update（IR3 内部版本 ：6.3.9600.17031）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17031" (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB2934018^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB2934018-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
)

:: Windows 8.1 with Update Refresh（IR4 内部版本 ：6.3.9600.17056）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17056" (
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3000850^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3000850-%ImageArchitecture%.cab"
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB3003057^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3003057-%ImageArchitecture%.cab"
)

:: Windows 8.1 with Update Refresh（IR5 内部版本 ：6.3.9600.17415）
if "%SelectedSourceOS%" equ "w81" if "%ImageServicePackBuild%" equ "17415" (
	if exist "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 WHD 基线功能包更新 ^(KB3021910^) 到恢复映像
		echo.---------------------------------[索引 ：1]------------------------------------
		call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB3021910-%ImageArchitecture%.cab"
	)
	echo.-------------------------------------------------------------------------------
	echo.正在集成 WHD 基线功能包更新 ^(KB4566425^) 到恢复映像
	echo.---------------------------------[索引 ：1]------------------------------------
	call :AddPackage "%WinReMount%", "%Temp%\Updates\Windows8.1-KB4566425-%ImageArchitecture%.cab"
)	

:: Windows 10
if "%SelectedSourceOS%" equ "w10" (
	if exist "%Temp%\Updates\ServicingStack\Update.mum" (
		if "%ImageBuild%" equ "10240" if "%ImageServicePackBuild%" equ "16384" (
			echo.-------------------------------------------------------------------------------
			echo.正在应用 Windows 10 v1507 累积更新集成修复
			echo.-------------------------------------------------------------------------------
			if "%ImageArchitecture%" equ "x86" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 1, "%WinReMount%"
			if "%ImageArchitecture%" equ "x64" call :ApplyImage "%W10CUFix%\TH1CUFix.tpk", 2, "%WinReMount%"
			call :MountImageRegistry "%WinReMount%"
			call :ImportRegistry2Image "%W10CUFix%\TH1CUFix_%ImageArchitecture%.reg" 2>nul
			call :UnMountImageRegistry
		)
		if "%ImageArchitecture%" equ "x86" if "%ImageBuild%" equ "14393" if "%ImageServicePackBuild%" equ "0" (
			echo.-------------------------------------------------------------------------------
			echo.正在应用 Windows 10 v1607 累积更新集成修复
			echo.-------------------------------------------------------------------------------
			call :ApplyImage "%W10CUFix%\RS1CUFix.tpk", 1, "%WinReMount%"
			call :MountImageRegistry "%WinReMount%"
			call :ImportRegistry2Image "%W10CUFix%\RS1CUFix.reg" 2>nul
			call :UnMountImageRegistry
		)
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 服务堆栈更新到恢复映像
		echo.---------------------------------[索引 ：1]------------------------------------
		call :AddPackage "%WinReMount%", "%Temp%\Updates\ServicingStack"
	)
	if exist "%Temp%\Updates\Cumulative\Update.mum" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 累积更新到恢复映像
		echo.---------------------------------[索引 ：1]------------------------------------
			call :AddPackage "%WinReMount%", "%Temp%\Updates\Cumulative"
	)
	if exist "%Temp%\Updates\WinPE\*.cab" (
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Windows 10 WinPE 更新到恢复映像
		echo.---------------------------------[索引 ：1]------------------------------------
		call :AddPackage "%WinReMount%", "%Temp%\Updates\WinPE"
	)
)

if "%IsLogsEnabled%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	if "%SelectedSourceOS%" equ "w81" echo.####正在生成 WHD 基线更新集成日志文件##########################################
	if "%SelectedSourceOS%" equ "w10" echo.####正在生成 WHD 常规更新集成日志文件##########################################
	echo.-------------------------------------------------------------------------------
	echo.
	for /l %%k in (1, 1, 2) do (
		if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [Boot.wim，索引 ：%%k] 集成日志……
		if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [Boot.wim，索引 ：%%k] 集成日志……
		call :GetPackages "%BootMount%\%%k", "Boot-%%k.txt"
		echo.
	)
	if "%ImageIndexNo%" equ "*" (
		if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [Install.wim，索引 ：1-%ImageCount%] 集成日志……
		if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [Install.wim，索引 ：1-%ImageCount%] 集成日志……
		for /L %%k in (1, 1, %ImageCount%) do (
			call :GetPackages "%InstallMount%\%%k", "Install-%%k.txt"
		)
	) else (
		if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [Install.wim，索引 ：%ImageIndexNo%] 集成日志……
		if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [Install.wim，索引 ：%ImageIndexNo%] 集成日志……
		call :GetPackages "%InstallMount%", "Install.txt"
	)
	echo.
	if "%SelectedSourceOS%" equ "w81" echo.正在写入 WHD 基线更新 [WinRe.wim，索引 ：1] 集成日志……
	if "%SelectedSourceOS%" equ "w10" echo.正在写入 WHD 常规更新 [WinRe.wim，索引 ：1] 集成日志……
	call :GetPackages "%WinReMount%", "Install_WinRE.txt"
	echo.
)

echo.-------------------------------------------------------------------------------
echo.####正在清理临时文件和文件夹###################################################
echo.-------------------------------------------------------------------------------
echo.
if "%SelectedSourceOS%" equ "w81" echo.正在清理 WHD 基线更新临时文件夹……
if "%SelectedSourceOS%" equ "w10" echo.正在清理 WHD 基线更新临时文件夹……
call :RemoveFolder "%Temp%\Updates"
echo.
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w81" echo.#############################集成 WHD 基线更新#################################
if "%SelectedSourceOS%" equ "w10" echo.#############################集成 WHD 常规更新#################################
echo.##############到 Windows 安装程序启动、安装和恢复映像已完成####################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set PackageArchitecture=
set Updates=

endlocal

:: 读取已更新的映像信息
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageIndexNo%" equ "*" (
		call :GetImageIndexInfo "%InstallWim%", 1 >nul
		call :MountImageRegistry "%InstallMount%\1"
		for /f "tokens=3 delims= " %%z in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do (set /a ImageServicePackBuild=%%z)
		call :UnMountImageRegistry
	) else (
		call :GetImageIndexInfo "%InstallWim%", %ImageIndexNo% >nul
		call :MountImageRegistry "%InstallMount%"
		for /f "tokens=3 delims= " %%z in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do (set /a ImageServicePackBuild=%%z)
		call :UnMountImageRegistry
	)
)

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成更新模块
:: 输入参数 [%~1 ：更新类型 ]
::-------------------------------------------------------------------------------------------
:IntUpdates

setlocal

:: 设置 WHD 更新类型
set "UpdateType=%~1"

cls
echo.===============================================================================
if "%UpdateType%" equ "WUpdates" echo.                       MSMG 工具箱 - 集成 Windows 更新
if "%UpdateType%" equ "General" echo.                       MSMG 工具箱 - 集成 WHD 常规更新
if "%UpdateType%" equ "Hotfix" echo.                      MSMG 工具箱 - 集成 WHD 热修复更新
if "%UpdateType%" equ "Security" echo.                       MSMG 工具箱 - 集成 WHD 安全更新
if "%UpdateType%" equ "NET35" echo.              MSMG 工具箱 - 集成 Microsoft .NET Framework 3.5 更新
if "%UpdateType%" equ "WAT" echo.                    MSMG 工具箱 - 集成 Windows 激活技术 ^(WAT^)
if "%UpdateType%" equ "Windows10" echo.                   MSMG 工具箱 - 集成 Windows 10 升级准备更新
if "%UpdateType%" equ "WinPE" echo.                       MSMG 工具箱 - 集成 Windows PE 更新
if "%UpdateType%" equ "WUSatisfy" echo.               MSMG 工具箱 - 集成 Windows Update Satisfy 更新
if "%UpdateType%" equ "ADLDS" echo.               MSMG 工具箱 - 集成 Active Directory 轻型目录服务
if "%UpdateType%" equ "FMApi" echo.                        MSMG 工具箱 - 集成文件管理 API
if "%UpdateType%" equ "Features" echo.                       MSMG 工具箱 - 集成 Windows 功能
if "%UpdateType%" equ "VirtualPC" echo.                 MSMG 工具箱 - 集成 Microsoft Virtual PC 功能
if "%UpdateType%" equ "WorkFolders" echo.             MSMG 工具箱 - 集成适用于域环境的同步代理 ^(工作文件夹^)
echo.===============================================================================
echo.
:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置 Windows/WHD 更新菜单文件夹路径
if "%UpdateType%" equ "WUpdates" set "Updates=%Updates%\%SelectedSourceOS%\%ImageArchitecture%"
if "%UpdateType%" neq "WUpdates" set "Updates=%WHD%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查 Windows/WHD 更新文件夹是否是空的
if "%UpdateType%" equ "WUpdates" if not exist "%Updates%\*.msu" if not exist "%Updates%\*.cab" (
	echo.Windows 更新文件夹 ^<Updates\%SelectedSourceOS%\%ImageArchitecture%^> 是空的……
	echo.
	echo.请复制 Windows 更新文件到相应的文件夹……
	goto :Stop
)

if "%UpdateType%" equ "General" (
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" if not exist "%Updates%\Extra\WithoutKB3125574\#General\*.msu" if not exist "%Updates%\Extra\WithoutKB3125574\#General\*.cab" (
		echo.WHD 常规更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\WithoutKB3125574\#General^> 是空的……
		echo.
		echo.请复制 WHD 常规更新文件到相应的文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" if not exist "%Updates%\General\*.msu" if not exist "%Updates%\General\*.cab" (
		echo.WHD 常规更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\General^> 是空的……
		echo.
		echo.请复制 WHD 常规更新文件到相应的文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%Updates%\General\*.msu" if not exist "%Updates%\General\*.cab" (
		echo.WHD 常规更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\General^> 是空的……
		echo.
		echo.请复制 WHD 常规更新文件到相应的文件夹……
		goto :Stop
	)
)

if "%UpdateType%" equ "Hotfix" (
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" if not exist "%Updates%\Extra\WithoutKB3125574\#Hotfix\*.msu" if not exist "%Updates%\Extra\WithoutKB3125574\#Hotfix\*.cab" (
		echo.WHD 热修复更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\WithoutKB3125574\#Hotfix^> 是空的……
		echo.
		echo.请复制 WHD 热修复更新文件到相应的文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" if not exist "%Updates%\Hotfix\*.msu" if not exist "%Updates%\Hotfix\*.cab" (
		echo.WHD 热修复更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Hotfix^> 是空的……
		echo.
		echo.请复制 WHD 热修复更新文件到相应的文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%Updates%\Hotfix\*.msu" if not exist "%Updates%\Hotfix\*.cab" (
		echo.WHD 热修复更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Hotfix^> 是空的……
		echo.
		echo.请复制 WHD 热修复更新文件到相应的文件夹……
		goto :Stop
	)	
)

if "%UpdateType%" equ "Security" (
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" if not exist "%Updates%\Extra\WithoutKB3125574\#Security\*.msu" if not exist "%Updates%\Extra\WithoutKB3125574\#Security\*.cab" (
		echo.WHD 安全更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\WithoutKB3125574\#Security^> 是空的……
		echo.
		echo.请复制 WHD 安全更新文件到相应的文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" if not exist "%Updates%\Security\WithoutESU\*.msu" if not exist "%Updates%\Security\WithoutESU\*.cab" (
		echo.WHD 安全更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Security\WithoutESU^> 是空的……
		echo.
		echo.请复制 WHD 安全更新文件到相应的文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" if not exist "%Updates%\Security\*.msu" if not exist "%Updates%\Security\*.cab" (
		echo.WHD 安全更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Security^> 是空的……
		echo.
		echo.请复制 WHD 安全更新文件到相应的文件夹……
		goto :Stop
	)
	if "%SelectedSourceOS%" equ "w81" if not exist "%Updates%\Security\*.msu" if not exist "%Updates%\Security\*.cab" (
		echo.WHD 安全更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Security^> 是空的……
		echo.
		echo.请复制 WHD 安全更新文件到相应的文件夹……
		goto :Stop
	)	
)

if "%UpdateType%" equ "NET35" if not exist "%Updates%\Additional\NET35\*.msu" if not exist "%Updates%\Additional\NET35\*.cab" (
	echo.	         Microsoft .NET Framework 3.5 更新文件夹
	echo.	       ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Additional\NET35^> 是空的……
	echo.
	echo.  请复制 Microsoft .NET Framework 3.5 更新文件到相应的文件夹……
	goto :Stop
)

if "%UpdateType%" equ "WAT" (
	if not exist "%Updates%\Additional\WAT\*.msu" if not exist "%Updates%\Additional\WAT\*.cab" (
		echo.                    Windows 激活技术文件夹
		echo.                 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Additional\WAT^> 是空的……
		echo.
		echo.          请复制 Windows 激活技术文件到相应的文件夹……
		goto :Stop
	)

	if "%ImageEdition%" equ "Embedded" (
		echo.Windows 激活技术需要客户端/服务器端版本……
		goto :Stop
	)
)

if "%UpdateType%" equ "Windows10" (
	if not exist "%Updates%\Additional\Windows10\*.msu" if not exist "%Updates%\Additional\Windows10\*.cab" (
		echo.                  Windows 10 升级准备更新文件夹
		echo.               ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Additional\Windows10^> 是空的……
		echo.
		echo.        请复制 Windows 10 升级准备更新文件到相应的文件夹……
		goto :Stop
	)
	
	if "%IsW7SP1CRUSelected%" equ "0" if not exist "%Updates%\Extra\WithoutKB3125574\_Windows10\*.msu" if not exist "%Updates%\Extra\WithoutKB3125574\_Windows10\*.cab" (
		echo.                  Windows 10 升级准备更新文件夹
		echo.       ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\WithoutKB3125574\_Windows10^> 是空的……
		echo.
		echo.        请复制 Windows 10 升级准备更新文件到相应的文件夹……
		goto :Stop
	)	

	if "%ImageEdition%" equ "Embedded" (
		echo.Windows 10 升级准备更新需要客户端版本……
		goto :Stop
	)
)

if "%UpdateType%" equ "WinPE" if not exist "%Updates%\Additional\WinPE\*.msu" if not exist "%Updates%\Additional\WinPE\*.cab" (
	echo.Windows PE 更新文件夹 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Additional\WinPE^> 是空的……
	echo.
	echo.请复制 Windows PE 更新文件到相应的文件夹……
	goto :Stop
)

if "%UpdateType%" equ "WUSatisfy" if not exist "%Updates%\Additional\WU.Satisfy\*.msu" if not exist "%Updates%\Additional\WU.Satisfy\*.cab" (
	echo.                      Windows Update Satisfy 更新文件夹
	echo.              ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Additional\WU.Satisfy^> 是空的……
	echo.
	echo.          请复制 Windows Update Satisfy Updates 文件到相应的文件夹……
	goto :Stop
)

if "%UpdateType%" equ "ADLDS" (
	if not exist "%Updates%\Extra\AD_LDS\*.msu" if not exist "%Updates%\Extra\AD_LDS\*.cab" (
		echo.                   Active Directory 轻型目录服务功能文件夹
		echo.                 ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\AD_LDS^> 是空的……
		echo.
		echo.                    请复制 ADLDS 功能文件到相应的文件夹……
		goto :Stop
	)
	if not exist "%Updates%\Extra\AD_LDS\Updates\*.msu" if not exist "%Updates%\Extra\AD_LDS\Updates\*.cab" (
		echo.                 Active Directory 轻型目录服务功能更新文件夹
		echo.           ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\AD_LDS\Updates^> 是空的……
		echo.
		echo.                  请复制 ADLDS 功能更新文件到相应的文件夹……
		goto :Stop
	)	
	if "%IsW7SP1CRUSelected%" equ "0" if not exist "%Updates%\Extra\WithoutKB3125574\AD_LDS\*.msu" if not exist "%Updates%\Extra\WithoutKB3125574\AD_LDS\*.cab" (
		echo.                 Active Directory 轻型目录服务功能更新文件夹
		echo.         ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\WithoutKB3125574\AD_LDS^> 是空的……
		echo.
		echo.                  请复制 ADLDS 功能更新文件到相应的文件夹……
		goto :Stop
	)

	if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "Ultimate" (
		echo.                     Active Directory 轻型目录服务功能
		echo.                         需要专业版/企业版/旗舰版……
		goto :Stop
	) else (
		goto :Continue
	)	
)

if "%UpdateType%" equ "FMApi" if not exist "%Updates%\Extra\Addons\FM.Api\*.msu" if not exist "%Updates%\Extra\Addons\FM.Api\*.cab" (
	echo.                        文件管理 API 文件夹
	echo.        ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\Addons\FM.Api^> 是空的……
	echo.
	echo.               请复制文件管理 API 文件到相应的文件夹……
	goto :Stop
)

if "%UpdateType%" equ "Features" if not exist "%Updates%\Extra\WithoutKB3125574\_Features\*.msu" if not exist "%Updates%\Extra\WithoutKB3125574\_Features\*.cab" (
	echo.                           Windows 功能文件夹
	echo.        ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\WithoutKB3125574\_Features^> 是空的……
	echo.
	echo.                请复制 Windows 功能文件到相应的文件夹……
	goto :Stop
)

if "%UpdateType%" equ "VirtualPC" (
	if not exist "%Updates%\Extra\VirtualPC\*.msu" if not exist "%Updates%\Extra\VirtualPC\*.cab" (
		echo.                     Microsoft Virtual PC 功能文件夹
		echo.                ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\VirtualPC^> 是空的……
		echo.
		echo.          请复制 Microsoft Virtual PC 功能文件到相应的文件夹……
		goto :Stop
	)
	if "%IsW7SP1CRUSelected%" equ "0" if not exist "%Updates%\Extra\WithoutKB3125574\VirtualPC\*.msu" if not exist "%Updates%\Extra\WithoutKB3125574\VirtualPC\*.cab" (
		echo.                   Microsoft Virtual PC 功能更新文件夹
		echo.       ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\WithoutKB3125574\VirtualPC^> 是空的……
		echo.
		echo.        请复制 Microsoft Virtual PC 功能更新文件到相应的文件夹……
		goto :Stop
	)	
)

if "%UpdateType%" equ "WorkFolders" (
	if not exist "%Updates%\Extra\Addons\WorkFolders\*.msu" if not exist "%Updates%\Extra\Addons\WorkFolders\*.cab" (
		echo.             适用于域环境的同步代理 ^(工作文件夹^) 功能文件夹
		echo.           ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\Addons\WorkFolders^> 是空的……
		echo.
		echo.                  请复制适用于域环境的同步代理 ^(工作文件夹^)
		echo.                        功能文件到相应的文件夹……
		goto :Stop
	)
	if "%IsW7SP1CRUSelected%" equ "0" if not exist "%Updates%\Extra\WithoutKB3125574\WorkFolders\*.msu" if not exist "%Updates%\Extra\WithoutKB3125574\WorkFolders\*.cab" (
		echo.            适用于域环境的同步代理 ^(工作文件夹^) 功能更新文件夹
		echo.      ^<WHD\%SelectedSourceOS%\%ImageArchitecture%\Extra\WithoutKB3125574\WorkFolders^> 是空的……
		echo.
		echo.                  请复制适用于域环境的同步代理 ^(工作文件夹^)
		echo.                       功能更新文件到相应的文件夹……
		goto :Stop
	)

	if "%ImageEdition%" neq "Professional" if "%ImageEdition%" neq "Enterprise" if "%ImageEdition%" neq "Ultimate" (
		echo.                 适用于域环境的同步代理 ^(工作文件夹^) 功能
		echo.                         需要专业版/企业版/旗舰版……
		goto :Stop
	) else (
		goto :Continue
	)
)

:Continue
echo.-------------------------------------------------------------------------------
if "%UpdateType%" equ "WUpdates" echo.####正在开始集成 Windows 更新##################################################
if "%UpdateType%" equ "General" echo.####正在开始集成 WHD 常规更新##################################################
if "%UpdateType%" equ "Hotfix" echo.####正在开始集成 WHD 热修复更新################################################
if "%UpdateType%" equ "Security" echo.####正在开始集成 WHD 安全更新##################################################
if "%UpdateType%" equ "NET35" echo.####正在开始集成 Microsoft .NET Framework 3.5 更新#############################
if "%UpdateType%" equ "WAT" echo.####正在开始集成 Windows 激活技术 ^(WAT^)########################################
if "%UpdateType%" equ "Windows10" echo.####正在开始集成 Windows 10 升级准备更新#######################################
if "%UpdateType%" equ "WinPE" echo.####正在开始集成 Windows PE 更新###############################################
if "%UpdateType%" equ "WUSatisfy" echo.####正在开始集成 Windows Update Satisfy 更新###################################
if "%UpdateType%" equ "ADLDS" echo.####正在开始集成 Active Directory 轻型目录服务#################################
if "%UpdateType%" equ "FMApi" echo.####正在开始集成文件管理 API###################################################
if "%UpdateType%" equ "Features" echo.####正在开始集成 Windows 功能##################################################
if "%UpdateType%" equ "VirtualPC" echo.####正在开始集成 Microsoft Virtual PC 功能#####################################
if "%UpdateType%" equ "WorkFolders" echo.####正在开始集成适用于域环境的同步代理 ^(工作文件夹^)############################
echo.-------------------------------------------------------------------------------
echo.
if "%UpdateType%" neq "WinPE" (
	echo.    映像文件名称             ：Install.wim
	if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
	if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
) else (
	echo.    映像文件名称             ：Boot.wim         ^|  WinRE.wim
	if "%ImageIndexNo%" neq "*" echo.    映像索引范围             ：   2             ^|    1
	if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：   2             ^|    1
)
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%UpdateType%" equ "WUpdates" echo.####正在处理 Windows 更新包####################################################
if "%UpdateType%" equ "General" echo.####正在处理 WHD 常规更新包####################################################
if "%UpdateType%" equ "Hotfix" echo.####正在处理 WHD 热修复更新包##################################################
if "%UpdateType%" equ "Security" echo.####正在处理 WHD 安全更新包####################################################
if "%UpdateType%" equ "NET35" echo.####正在处理 Microsoft .NET Framework 3.5 更新包###############################
if "%UpdateType%" equ "WAT" echo.####正在处理 Windows 激活技术 ^(WAT^) 包#########################################
if "%UpdateType%" equ "Windows10" echo.####正在处理 Windows 10 升级准备更新包#########################################
if "%UpdateType%" equ "WinPE" echo.####正在处理 Windows PE 更新包#################################################
if "%UpdateType%" equ "WUSatisfy" echo.####正在处理 Windows Update Satisfy 更新包#####################################
if "%UpdateType%" equ "ADLDS" echo.####正在处理Active Directory 轻型目录服务包###########################################
if "%UpdateType%" equ "FMApi" echo.####正在处理文件管理 API 包####################################################
if "%UpdateType%" equ "Features" echo.####正在处理 Windows 功能包####################################################
if "%UpdateType%" equ "VirtualPC" echo.####正在处理 Microsoft Virtual PC 功能包#######################################
if "%UpdateType%" equ "WorkFolders" echo.####正在处理适用于域环境的同步代理 ^(工作文件夹^) 包#############################
echo.-------------------------------------------------------------------------------
echo.
:: 创建 Windows/WHD 更新临时文件夹
if "%UpdateType%" equ "WUpdates" echo.正在创建 Windows 更新包临时文件夹……
if "%UpdateType%" equ "General" echo.正在创建 WHD 常规更新包临时文件夹……
if "%UpdateType%" equ "Hotfix" echo.正在创建 WHD 热修复更新包临时文件夹……
if "%UpdateType%" equ "Security" echo.正在创建 WHD 安全更新包临时文件夹……
if "%UpdateType%" equ "NET35" echo.正在创建 Microsoft .NET Framework 3.5 更新包临时文件夹……
if "%UpdateType%" equ "WAT" echo.正在创建 Windows 激活技术包临时文件夹……
if "%UpdateType%" equ "Windows10" echo.正在创建 Windows 10 升级准备更新包临时文件夹……
if "%UpdateType%" equ "WinPE" echo.正在创建 Windows PE 更新包临时文件夹……
if "%UpdateType%" equ "WUSatisfy" echo.正在创建 Windows Update Satisfy Update 包临时文件夹……
if "%UpdateType%" equ "ADLDS" echo.正在创建 ADLDS 包临时文件夹……
if "%UpdateType%" equ "FMApi" echo.正在创建文件管理 API 包临时文件夹……
if "%UpdateType%" equ "Features" echo.正在创建 Windows 功能包临时文件夹……
if "%UpdateType%" equ "VirtualPC" echo.正在创建 Microsoft Virtual PC 功能包临时文件夹……
if "%UpdateType%" equ "WorkFolders" echo.正在创建适用于域环境的同步代理包临时文件夹……
echo.

call :RemoveFolder "%Temp%\Updates"
call :CreateFolder "%Temp%\Updates"

if "%UpdateType%" equ "General" call :CreateFolder "%Temp%\Updates\%UpdateType%"
if "%UpdateType%" equ "Hotfix" call :CreateFolder "%Temp%\Updates\%UpdateType%"
if "%UpdateType%" equ "Security" (
	call :CreateFolder "%Temp%\Updates\%UpdateType%" >nul
	if "%SelectedSourceOS%" equ "w81" call :CreateFolder "%Temp%\Updates\%UpdateType%\ProWMC"
)
if "%UpdateType%" equ "NET35" call :CreateFolder "%Temp%\Updates\%UpdateType%"
if "%UpdateType%" equ "WAT" call :CreateFolder "%Temp%\Updates\%UpdateType%"
if "%UpdateType%" equ "Windows10" call :CreateFolder "%Temp%\Updates\%UpdateType%"
if "%UpdateType%" equ "WinPE" call :CreateFolder "%Temp%\Updates\%UpdateType%"
if "%UpdateType%" equ "WUSatisfy" call :CreateFolder "%Temp%\Updates\%UpdateType%\ProfessionalWMC"
if "%UpdateType%" equ "ADLDS" call :CreateFolder "%Temp%\Updates\%UpdateType%\Updates"
if "%UpdateType%" equ "FMApi" call :CreateFolder "%Temp%\Updates\%UpdateType%\Updates"
if "%UpdateType%" equ "Features" call :CreateFolder "%Temp%\Updates\%UpdateType%"
if "%UpdateType%" equ "VirtualPC" (
	if "%IsW7SP1CRUSelected%" equ "1" call :CreateFolder "%Temp%\Updates\%UpdateType%"
	if "%IsW7SP1CRUSelected%" equ "0" call :CreateFolder "%Temp%\Updates\%UpdateType%\Updates"
)
if "%UpdateType%" equ "WorkFolders" (
	if "%IsW7SP1CRUSelected%" equ "1" call :CreateFolder "%Temp%\Updates\%UpdateType%"
	if "%IsW7SP1CRUSelected%" equ "0" call :CreateFolder "%Temp%\Updates\%UpdateType%\Updates"
)

echo.正在解压 .CAB 软件包文件到临时文件夹……
echo.

:: 解压/复制 Windows/WHD 更新 .CAB 文件到临时文件夹
if "%UpdateType%" equ "WUpdates" (
	if exist "%Updates%\*%ImageArchitecture%*.msu" expand "%Updates%\*.msu" -F:Win*.cab "%Temp%\Updates" >nul
	if exist "%Updates%\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\*.cab" "%Temp%\Updates" >nul
)
if "%UpdateType%" equ "General" (
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" (
		if exist "%Updates%\Extra\WithoutKB3125574\#General\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\WithoutKB3125574\#General\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\Extra\WithoutKB3125574\#General\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\WithoutKB3125574\#General\*.cab" "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Temp%\Updates\%UpdateType%\WUClient*.cab" (
			call :CreateFolder "%Temp%\Updates\%UpdateType%\WUClient"
			move /y "%Temp%\Updates\%UpdateType%\WUClient*.cab" "%Temp%\Updates\%UpdateType%\WUClient" >nul
		)
	)
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" (
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\*.cab" "%Temp%\Updates\%UpdateType%" >nul

		call :CreateFolder "%Temp%\Updates\%UpdateType%\SP2"
		move /y "%Temp%\Updates\%UpdateType%\Windows6.1-KB4490628-%ImageArchitecture%.cab" "%Temp%\Updates\%UpdateType%\SP2" >nul
		move /y "%Temp%\Updates\%UpdateType%\Windows6.1-KB2670838-%ImageArchitecture%.cab" "%Temp%\Updates\%UpdateType%\SP2" >nul
		move /y "%Temp%\Updates\%UpdateType%\Windows6.1-KB3125574-v4-%ImageArchitecture%.cab" "%Temp%\Updates\%UpdateType%\SP2" >nul
		move /y "%Temp%\Updates\%UpdateType%\Windows6.1-KB3172605-%ImageArchitecture%.cab" "%Temp%\Updates\%UpdateType%\SP2" >nul
	
		call :CreateFolder "%Temp%\Updates\%UpdateType%\Client"
		if exist "%Temp%\Updates\%UpdateType%\Windows6.1-KB917607-%ImageArchitecture%.cab" del /f /q "%Temp%\Updates\%UpdateType%\Windows6.1-KB917607-%ImageArchitecture%.cab" >nul
	)
	if "%SelectedSourceOS%" equ "w81" (
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\*.cab" "%Temp%\Updates\%UpdateType%" >nul

		if exist "%Temp%\Updates\%UpdateType%\Windows8.1-KB3140185-%ImageArchitecture%.cab" (
			call :CreateFolder "%Temp%\Updates\%UpdateType%\Upgrade"
			move /y "%Temp%\Updates\%UpdateType%\Windows8.1-KB3140185-%ImageArchitecture%.cab" "%Temp%\Updates\%UpdateType%\Upgrade" >nul
		)
	
		if exist "%Temp%\Updates\%UpdateType%\Windows8.1-KB917607-%ImageArchitecture%.cab" del /f /q "%Temp%\Updates\%UpdateType%\Windows8.1-KB917607-%ImageArchitecture%.cab" >nul
		if exist "%Temp%\Updates\%UpdateType%\Windows8.1-KB4486105-%ImageArchitecture%.cab" del /f /q "%Temp%\Updates\%UpdateType%\Windows8.1-KB4486105-%ImageArchitecture%.cab" >nul
	)
)
if "%UpdateType%" equ "Hotfix" (
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" (
		if exist "%Updates%\Extra\WithoutKB3125574\#Hotfix\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\WithoutKB3125574\#Hotfix\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\Extra\WithoutKB3125574\#Hotfix\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\WithoutKB3125574\#Hotfix\*.cab" "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Temp%\Updates\%UpdateType%\Windows6.1-KB2780124-%ImageArchitecture%*.cab" (
			call :CreateFolder "%Temp%\Updates\%UpdateType%\Ent_Ultimate"
			move /y "%Temp%\Updates\%UpdateType%\Windows6.1-KB2780124-%ImageArchitecture%*.cab" "%Temp%\Updates\%UpdateType%\Ent_Ultimate" >nul
		)		
	)
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" (
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\*.cab" "%Temp%\Updates\%UpdateType%" >nul

		call :CreateFolder "%Temp%\Updates\%UpdateType%\Client"
		if exist "%Temp%\Updates\%UpdateType%\Windows6.1-KB2727994-v3-%ImageArchitecture%.cab" move /y "%Temp%\Updates\%UpdateType%\Windows6.1-KB2727994-v3-%ImageArchitecture%.cab" "%Temp%\Updates\%UpdateType%\Client" >nul
	)
	if "%SelectedSourceOS%" equ "w81" (
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\*.cab" "%Temp%\Updates\%UpdateType%" >nul
	)
)
if "%UpdateType%" equ "Security" (
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" (
		if exist "%Updates%\Extra\WithoutKB3125574\#Security\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\WithoutKB3125574\#Security\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\Extra\WithoutKB3125574\#Security\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\WithoutKB3125574\#Security\*.cab" "%Temp%\Updates\%UpdateType%" >nul

		if exist "%Updates%\%UpdateType%\Windows6.1-KB4490628-%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\Windows6.1-KB4490628-%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\Windows6.1-KB4490628-%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\Windows6.1-KB4490628-%ImageArchitecture%*.cab" "%Temp%\Updates\%UpdateType%" >nul
	)
	if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" (
		if exist "%Updates%\%UpdateType%\WithoutESU\*%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\WithoutESU\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\WithoutESU\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\WithoutESU\*.cab" "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\*.cab" "%Temp%\Updates\%UpdateType%" >nul
	)
	if "%SelectedSourceOS%" equ "w81" (
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\*.cab" "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\NET452\*%ImageArchitecture%*.msu" expand "%Updates%\%UpdateType%\NET452\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\%UpdateType%\NET452\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\%UpdateType%\NET452\*.cab" "%Temp%\Updates\%UpdateType%" >nul
	)
)

if "%UpdateType%" equ "NET35" (
	if exist "%Updates%\Additional\NET35\*%ImageArchitecture%*.msu" expand "%Updates%\Additional\NET35\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Additional\NET35\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Additional\NET35\*.cab" "%Temp%\Updates\%UpdateType%" >nul
)

if "%UpdateType%" equ "WAT" (
	if exist "%Updates%\Additional\WAT\*%ImageArchitecture%*.msu" expand "%Updates%\Additional\WAT\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Additional\WAT\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Additional\WAT\*.cab" "%Temp%\Updates\%UpdateType%" >nul
)

if "%UpdateType%" equ "Windows10" (
	if exist "%Updates%\Additional\Windows10\*%ImageArchitecture%*.msu" expand "%Updates%\Additional\Windows10\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Additional\Windows10\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Additional\Windows10\*.cab" "%Temp%\Updates\%UpdateType%" >nul
	if "%IsW7SP1CRUSelected%" equ "0" (
		if exist "%Updates%\Extra\WithoutKB3125574\_Windows10\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\WithoutKB3125574\_Windows10\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
		if exist "%Updates%\Extra\WithoutKB3125574\_Windows10\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\WithoutKB3125574\_Windows10\*.cab" "%Temp%\Updates\%UpdateType%" >nul
	)
)

if "%UpdateType%" equ "WinPE" (
	if exist "%Updates%\Additional\WinPE\*%ImageArchitecture%*.msu" expand "%Updates%\Additional\WinPE\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Additional\WinPE\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Additional\WinPE\*.cab" "%Temp%\Updates\%UpdateType%" >nul

	if exist "%Updates%\General\Windows8.1-KB3084905*%ImageArchitecture%*.msu" expand "%Updates%\General\Windows8.1-KB3084905*%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\General\Windows8.1-KB3084905*%ImageArchitecture%*.cab" %XCopy% "%Updates%\General\Windows8.1-KB3084905*%ImageArchitecture%*.cab" "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\General\Windows8.1-KB3115224*%ImageArchitecture%*.msu" expand "%Updates%\General\Windows8.1-KB3115224*%ImageArchitecture%*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\General\Windows8.1-KB3115224*%ImageArchitecture%*.cab" %XCopy% "%Updates%\General\Windows8.1-KB3115224*%ImageArchitecture%*.cab" "%Temp%\Updates\%UpdateType%" >nul
)

if "%UpdateType%" equ "WUSatisfy" (
	if exist "%Updates%\Additional\WU.Satisfy\*%ImageArchitecture%*.msu" expand "%Updates%\Additional\WU.Satisfy\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Additional\WU.Satisfy\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Additional\WU.Satisfy\*.cab" "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Additional\WU.Satisfy\ProfessionalWMC\*%ImageArchitecture%*.msu" expand "%Updates%\Additional\WU.Satisfy\ProfessionalWMC\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%\ProfessionalWMC" >nul
	if exist "%Updates%\Additional\WU.Satisfy\ProfessionalWMC\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Additional\WU.Satisfy\ProfessionalWMC\*.cab" "%Temp%\Updates\%UpdateType%\ProfessionalWMC" >nul
)

if "%UpdateType%" equ "ADLDS" (
	if exist "%Updates%\Extra\AD_LDS\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\AD_LDS\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Extra\AD_LDS\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\AD_LDS\*.cab" "%Temp%\Updates\%UpdateType%" >nul

	if exist "%Updates%\Extra\AD_LDS\Updates\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\AD_LDS\Updates\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%\Updates" >nul
	if exist "%Updates%\Extra\AD_LDS\Updates\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\AD_LDS\Updates\*.cab" "%Temp%\Updates\%UpdateType%\Updates" >nul

	if "%IsW7SP1CRUSelected%" equ "0" (	
		if exist "%Updates%\Extra\WithoutKB3125574\AD_LDS\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\WithoutKB3125574\AD_LDS\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%\Updates" >nul
		if exist "%Updates%\Extra\WithoutKB3125574\AD_LDS\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\WithoutKB3125574\AD_LDS\*.cab" "%Temp%\Updates\%UpdateType%\Updates" >nul
	)
)

if "%UpdateType%" equ "FMApi" (
	if exist "%Updates%\Extra\Addons\FM.Api\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\Addons\FM.Api\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Extra\Addons\FM.Api\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\Addons\FM.Api\*.cab" "%Temp%\Updates\%UpdateType%" >nul
)

if "%UpdateType%" equ "Features" (
	if exist "%Updates%\Extra\WithoutKB3125574\_Features\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\WithoutKB3125574\_Features\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Extra\WithoutKB3125574\_Features\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\WithoutKB3125574\_Features\*.cab" "%Temp%\Updates\%UpdateType%" >nul
)

if "%UpdateType%" equ "VirtualPC" (
	if exist "%Updates%\Extra\VirtualPC\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\VirtualPC\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Extra\VirtualPC\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\VirtualPC\*.cab" "%Temp%\Updates\%UpdateType%" >nul
	if "%IsW7SP1CRUSelected%" equ "0" (
		if exist "%Updates%\Extra\WithoutKB3125574\VirtualPC\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\WithoutKB3125574\VirtualPC\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%\Updates" >nul
		if exist "%Updates%\Extra\WithoutKB3125574\VirtualPC\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\WithoutKB3125574\VirtualPC\*.cab" "%Temp%\Updates\%UpdateType%\Updates" >nul
	)
)

if "%UpdateType%" equ "WorkFolders" (
	if exist "%Updates%\Extra\Addons\WorkFolders\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\Addons\WorkFolders\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%" >nul
	if exist "%Updates%\Extra\Addons\WorkFolders\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\Addons\WorkFolders\*.cab" "%Temp%\Updates\%UpdateType%" >nul
	if "%IsW7SP1CRUSelected%" equ "0" (
		if exist "%Updates%\Extra\WithoutKB3125574\WorkFolders\*%ImageArchitecture%*.msu" expand "%Updates%\Extra\WithoutKB3125574\WorkFolders\*.msu" -F:Win*.cab "%Temp%\Updates\%UpdateType%\Updates" >nul
		if exist "%Updates%\Extra\WithoutKB3125574\WorkFolders\*%ImageArchitecture%*.cab" %XCopy% "%Updates%\Extra\WithoutKB3125574\WorkFolders\*.cab" "%Temp%\Updates\%UpdateType%\Updates" >nul
	)
)

echo.解压 .CAB 软件包文件到临时文件夹已完成……
echo.
echo.-------------------------------------------------------------------------------
:: 集成 Windows/WHD 更新包到 WIM 映像
if "%UpdateType%" equ "WUpdates" echo.####正在集成 Windows 更新######################################################
if "%UpdateType%" equ "General" echo.####正在集成 WHD 一般更新######################################################
if "%UpdateType%" equ "Hotfix" echo.####正在集成 WHD 热修复更新####################################################
if "%UpdateType%" equ "Security" echo.####正在集成 WHD 安全更新######################################################
if "%UpdateType%" equ "NET35" echo.####正在集成 Microsoft .NET Framework 3.5 更新#################################
if "%UpdateType%" equ "WAT" echo.####正在集成 Windows 激活技术 ^(WAT^) ###########################################
if "%UpdateType%" equ "Windows10" echo.####正在集成 Windows 10 升级准备更新###########################################
if "%UpdateType%" equ "WinPE" echo.####正在集成 Windows PE 更新###################################################
if "%UpdateType%" equ "WUSatisfy" echo.####正在集成 Windows Update Satisfy Update#####################################
if "%UpdateType%" equ "ADLDS" echo.####正在集成 Active Directory 轻型目录服务功能########################################
if "%UpdateType%" equ "FMApi" echo.####正在集成文件管理 API 功能##################################################
if "%UpdateType%" equ "Features" echo.####正在集成 Windows 功能更新##################################################
if "%UpdateType%" equ "VirtualPC" echo.####正在集成 Microsoft Virtual PC 功能#########################################
if "%UpdateType%" equ "WorkFolders" echo.####正在集成适用于域环境的同步代理 ^(工作文件夹^)################################
echo.-------------------------------------------------------------------------------

if "%UpdateType%" equ "WUpdates" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates"
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates"
	)
)

if "%UpdateType%" equ "General" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

			call :GetImageEdition "%InstallWim%", %%i
			
			if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" (
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"

				if exist "%Temp%\Updates\%UpdateType%\WUClient\WUClient*.cab" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 7 - Windows 更新客户端更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\WUClient\WUClient-SelfUpdate-Core-%ImageArchitecture%-7.6.7600.320.cab"
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\WUClient\WUClient-SelfUpdate-Aux-%ImageArchitecture%-7.6.7600.320.cab"
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\WUClient\WUClient-SelfUpdate-ActiveX-%ImageArchitecture%-7.6.7600.320.cab"
				)
			)
			
			if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" (
				echo.
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 SP1 便捷汇总先决条件更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\SP2\Windows6.1-KB4490628-%ImageArchitecture%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 SP1 便捷汇总平台更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\SP2\Windows6.1-KB2670838-%ImageArchitecture%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 SP1 便捷汇总更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\SP2\Windows6.1-KB3125574-v4-%ImageArchitecture%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 SP1 2016 年 7 月汇总更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\SP2\Windows6.1-KB3172605-%ImageArchitecture%.cab"
				echo.-------------------------------------------------------------------------------
				echo.正在集成 WHD 常规更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
				
				if "%ImageInstallationType%" neq "Embedded" if exist "%Temp%\Updates\%UpdateType%\Client\*.cab" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 7 客户端更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Client"
				)
			)

			if "%SelectedSourceOS%" equ "w81" (
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
			
				if exist "%Temp%\Updates\%UpdateType%\Upgrade\*.cab" (
					if "%ImageEdition%" equ "Core" (
						echo.-------------------------------------------------------------------------------
						echo.正在集成 Windows 8.1 可升级版更新包……
						echo.-------------------------------------------------------------------------------
						call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Upgrade"
					)
					if "%ImageEdition%" equ "CoreSingleLanguage" (
						echo.-------------------------------------------------------------------------------
						echo.正在集成 Windows 8.1 可升级版更新包……
						echo.-------------------------------------------------------------------------------
						call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Upgrade"
					)
					if "%ImageEdition%" equ "CoreCountrySpecific" (
						echo.-------------------------------------------------------------------------------
						echo.正在集成 Windows 8.1 可升级版更新包……
						echo.-------------------------------------------------------------------------------
						call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Upgrade"
					)
					if "%ImageEdition%" equ "Professional" if not exist "%InstallMount%\%%i\Windows\Servicing\Packages\Microsoft-Windows-Security-SPP-Component-SKU-Professional-GVLK-Package*.mum" (
						echo.-------------------------------------------------------------------------------
						echo.正在集成 Windows 8.1 可升级版更新包……
						echo.-------------------------------------------------------------------------------
						call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Upgrade"
					)
				)
			)
		)
	) else (
		if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" (
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"

			if exist "%Temp%\Updates\%UpdateType%\WUClient\WUClient*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 - Windows 更新客户端更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\WUClient\WUClient-SelfUpdate-Core-%ImageArchitecture%-7.6.7600.320.cab"
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\WUClient\WUClient-SelfUpdate-Aux-%ImageArchitecture%-7.6.7600.320.cab"
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\WUClient\WUClient-SelfUpdate-ActiveX-%ImageArchitecture%-7.6.7600.320.cab"
			)
		)
	
		if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" (
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 7 SP1 便捷汇总先决条件更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\SP2\Windows6.1-KB4490628-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 7 SP1 便捷汇总平台更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\SP2\Windows6.1-KB2670838-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 7 SP1 便捷汇总更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\SP2\Windows6.1-KB3125574-v4-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 7 SP1 2016 年 7 月汇总更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\SP2\Windows6.1-KB3172605-%ImageArchitecture%.cab"
			echo.-------------------------------------------------------------------------------
			echo.正在集成 WHD 常规更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
			
			if "%ImageInstallationType%" neq "Embedded" if exist "%Temp%\Updates\%UpdateType%\Client\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 客户端更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Client"
			)			
		)

		if "%SelectedSourceOS%" equ "w81" (
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
				
			if exist "%Temp%\Updates\%UpdateType%\Upgrade\*.cab" (
				if "%ImageEdition%" equ "Core" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 8.1 可升级版更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Upgrade"
				)
				if "%ImageEdition%" equ "CoreSingleLanguage" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 8.1 可升级版更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Upgrade"
				)
				if "%ImageEdition%" equ "CoreCountrySpecific" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 8.1 可升级版更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Upgrade"
				)
				if "%ImageEdition%" equ "Professional" if not exist "%InstallMount%\Windows\Servicing\Packages\Microsoft-Windows-Security-SPP-Component-SKU-Professional-GVLK-Package*.mum" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 8.1 可升级版更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Upgrade"
				)
			)
		)
	)
)

if "%UpdateType%" equ "Hotfix" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

			call :GetImageEdition "%InstallWim%", %%i
						
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
			
			if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" if exist "%Temp%\Updates\%UpdateType%\Ent_Ultimate\*.cab" (
				if "%ImageEdition%" equ "Enterprise" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 7 企业版更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Ent_Ultimate"
				)
				
				if "%ImageEdition%" equ "Ultimate"  (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 7 旗舰版更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Ent_Ultimate"
				)
			)
			
			if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" if "%ImageInstallationType%" neq "Embedded" if exist "%Temp%\Updates\%UpdateType%\Client\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 客户端更新包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Client"
			)
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"

		if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "0" if exist "%Temp%\Updates\%UpdateType%\Ent_Ultimate\*.cab" (
			if "%ImageEdition%" equ "Enterprise" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 企业版 Updates 软件包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Ent_Ultimate"
			)
				
			if "%ImageEdition%" equ "Ultimate"  (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Windows 7 旗舰版 Updates 软件包……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Ent_Ultimate"
			)
		)

		if "%SelectedSourceOS%" equ "w7" if "%IsW7SP1CRUSelected%" equ "1" if "%ImageInstallationType%" neq "Embedded" if exist "%Temp%\Updates\%UpdateType%\Client\*.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 7 客户端更新包……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Client"
		)    
	)
)

if "%UpdateType%" equ "Security" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

			call :GetImageEdition "%InstallWim%", %%i >nul
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"

			:: 应用反 Microsoft 遥测客户端补丁
			call :MountImageRegistry "%InstallMount%\%%i"
			Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\DiagTrack" /v "Start" /t REG_DWORD /d "4" /f >nul
			Reg delete "HKLM\TK_SYSTEM\ControlSet001\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener" /f >nul 2>&1
			Reg delete "HKLM\TK_SYSTEM\ControlSet001\Control\WMI\AutoLogger\SQMLogger" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack" /f >nul 2>&1
			call :UnMountImageRegistry
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"

		:: 应用反 Microsoft 遥测客户端补丁
		call :MountImageRegistry "%InstallMount%"
		Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\DiagTrack" /v "Start" /t REG_DWORD /d "4" /f >nul
		Reg delete "HKLM\TK_SYSTEM\ControlSet001\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener" /f >nul 2>&1
		Reg delete "HKLM\TK_SYSTEM\ControlSet001\Control\WMI\AutoLogger\SQMLogger" /f >nul 2>&1
		Reg delete "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack" /f >nul 2>&1
		call :UnMountImageRegistry
	)
)

if "%UpdateType%" equ "NET35" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
	)
)

if "%UpdateType%" equ "WAT" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
	)
)

if "%UpdateType%" equ "Windows10" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
	)
)

if "%UpdateType%" equ "WinPE" (
	echo.
	if "%IsBootImageSelected%" equ "Yes" (
		echo.-------------------------------------------------------------------------------
		echo.                  正在集成 Windows PE 更新到 Boot.wim 映像
		echo.---------------------------------[索引 ：2]------------------------------------
		call :AddPackage "%BootMount%\2", "%Temp%\Updates\%UpdateType%"
	)

	if "%IsBootImageSelected%" equ "Yes" (
		echo.-------------------------------------------------------------------------------
		echo.                  正在集成 Windows PE 更新到 WinRE.wim 映像
		echo.---------------------------------[索引 ：1]------------------------------------
		call :AddPackage "%WinReMount%", "%Temp%\Updates\%UpdateType%"	
	)
)

if "%UpdateType%" equ "WUSatisfy" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
			
			if exist "%Temp%\Updates\%UpdateType%\ProfessionalWMC\*.cab" (
				call :GetImageEdition "%InstallWim%", %%i >nul
				
				if "%ImageEdition%" equ "ProfessionalWMC" (
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Windows 8.1 专业版 ^(含 Media Center^) - Windows Update Satisfy 更新……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\ProfessionalWMC"
				)
			)
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
		
		if "%ImageEdition%" equ "ProfessionalWMC" if exist "%Temp%\Updates\%UpdateType%\ProfessionalWMC\*.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Windows 8.1 专业版 ^(含 Media Center^) - Windows Update Satisfy 更新……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\ProfessionalWMC"
		)
	)
)

if "%UpdateType%" equ "ADLDS" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

			call :GetImageEdition "%InstallWim%", %%i

			for /d %%j in (Professional, Enterprise, Ultimate) do (
				if "%ImageEdition%" equ "%%j" (
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
					
					echo.-------------------------------------------------------------------------------
					echo.正在集成 Active Directory 轻型目录服务更新包……
					echo.-------------------------------------------------------------------------------
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Updates"
				)
			)
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
			
		echo.-------------------------------------------------------------------------------
		echo.正在集成 Active Directory 轻型目录服务更新包……
		echo.-------------------------------------------------------------------------------
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Updates"
	)
)

if "%UpdateType%" equ "FMApi" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
	)
)

if "%UpdateType%" equ "Features" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"
	)
)

if "%UpdateType%" equ "VirtualPC" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
			call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
			
			if "%IsW7SP1CRUSelected%" equ "0"  if exist "%Temp%\Updates\%UpdateType%\Updates\*.cab" (
				echo.-------------------------------------------------------------------------------
				echo.正在集成 Microsoft Virtual PC 功能更新……
				echo.-------------------------------------------------------------------------------
				call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Updates"
			)
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"

		if "%IsW7SP1CRUSelected%" equ "0"  if exist "%Temp%\Updates\%UpdateType%\Updates\*.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft Virtual PC 功能更新……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Updates"
		)		
	)
)

if "%UpdateType%" equ "WorkFolders" (
	if "%ImageIndexNo%" equ "*" (
		echo.
		for /L %%i in (1, 1, %ImageCount%) do (
			if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
			if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

			call :GetImageEdition "%InstallWim%", %%i

			for /d %%j in (Professional, Enterprise, Ultimate) do (
				if "%ImageEdition%" equ "%%j" (
					call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%"
			
					if "%IsW7SP1CRUSelected%" equ "0" if exist "%Temp%\Updates\%UpdateType%\Updates\*.cab" (
						echo.-------------------------------------------------------------------------------
						echo.正在集成 Microsoft 工作文件夹功能更新……
						echo.-------------------------------------------------------------------------------
						call :AddPackage "%InstallMount%\%%i", "%Temp%\Updates\%UpdateType%\Updates"
					)
				)
			)
		)
	) else (
		call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%"

		if "%IsW7SP1CRUSelected%" equ "0" if exist "%Temp%\Updates\%UpdateType%\Updates\*.cab" (
			echo.-------------------------------------------------------------------------------
			echo.正在集成 Microsoft 工作文件夹功能更新……
			echo.-------------------------------------------------------------------------------
			call :AddPackage "%InstallMount%", "%Temp%\Updates\%UpdateType%\Updates"
		)		
	)
)

if "%IsLogsEnabled%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	if "%UpdateType%" equ "WUpdates" echo.####正在生成 Windows 更新集成日志文件##########################################
	if "%UpdateType%" equ "General" echo.####正在生成 WHD 常规更新集成日志文件##########################################
	if "%UpdateType%" equ "Hotfix" echo.####正在生成 WHD 热修复更新集成日志文件########################################
	if "%UpdateType%" equ "Security" echo.####正在生成 WHD 安全更新集成日志文件##########################################
	if "%UpdateType%" equ "NET35" echo.####正在生成 Microsoft .NET Framework 3.5 更新集成日志文件#####################
	if "%UpdateType%" equ "WAT" echo.####正在生成 Windows 激活技术 ^(WAT^) 集成日志###################################
	if "%UpdateType%" equ "Windows10" echo.####正在生成 Windows 10 升级准备更新集成日志###################################
	if "%UpdateType%" equ "WinPE" echo.####正在生成 Windows PE 更新集成日志###########################################
	if "%UpdateType%" equ "WUSatisfy" echo.####正在生成 Windows Update Satisfy Update 集成日志文件########################
	if "%UpdateType%" equ "ADLDS" echo.####正在生成 Active Directory 轻型目录服务集成日志#############################
	if "%UpdateType%" equ "FMApi" echo.####正在生成文件管理 API 集成日志##############################################
	if "%UpdateType%" equ "Features" echo.####正在生成 Windows 功能包集成日志文件########################################
	if "%UpdateType%" equ "VirtualPC" echo.####正在生成 Microsoft Virtual PC 功能集成日志文件#############################
	if "%UpdateType%" equ "WorkFolders" echo.####正在生成工作文件夹集成日志文件#############################################
	echo.-------------------------------------------------------------------------------
	echo.
	:: 写入 Windows/WHD 更新集成日志文件
	if "%UpdateType%" equ "WUpdates" echo.正在写入 Windows 更新集成日志文件……
	if "%UpdateType%" equ "General" echo.正在写入 WHD 常规更新集成日志文件……
	if "%UpdateType%" equ "Hotfix" echo.正在写入 WHD 热修复更新集成日志文件……
	if "%UpdateType%" equ "Security" echo.正在写入 WHD 安全更新集成日志文件……
	if "%UpdateType%" equ "NET35" echo.正在写入 Microsoft .NET Framework 3.5 更新集成日志文件……
	if "%UpdateType%" equ "WAT" echo.正在写入 Windows 激活技术集成日志文件……
	if "%UpdateType%" equ "Windows10" echo.正在写入 Windows 10 升级准备更新集成日志文件……
	if "%UpdateType%" equ "WinPE" echo.正在写入 Windows PE 更新集成日志文件……
	if "%UpdateType%" equ "WUSatisfy" echo.正在写入 Windows Update Satisfy 更新集成日志文件……
	if "%UpdateType%" equ "ADLDS" echo.正在写入 Active Directory 轻型目录服务集成日志文件……
	if "%UpdateType%" equ "FMApi" echo.正在写入文件管理 API 集成日志文件……
	if "%UpdateType%" equ "Features" echo.正在写入 Windows 功能包集成日志文件……
	if "%UpdateType%" equ "VirtualPC" echo.正在写入 Microsoft Virtual PC 功能集成日志文件……
	if "%UpdateType%" equ "WorkFolders" echo.正在写入工作文件夹集成日志文件……
	
	if "%ImageIndexNo%" equ "*" (
		for /L %%i in (1, 1, %ImageCount%) do (
			call :GetPackages "%InstallMount%\%%i", "Updates-%%i.txt"
		)
	) else (
		call :GetPackages "%InstallMount%", "Updates.txt"
	)
	echo.
)

echo.-------------------------------------------------------------------------------
echo.####正在清理临时文件和文件夹###################################################
echo.-------------------------------------------------------------------------------
echo.
:: 清理 Windows/WHD 更新临时文件夹
if "%UpdateType%" equ "WUpdates" echo.正在清理 Windows 更新临时文件夹……
if "%UpdateType%" equ "General" echo.正在清理 WHD 基线更新临时文件夹……
if "%UpdateType%" equ "Hotfix" echo.正在清理 WHD 热修复更新临时文件夹……
if "%UpdateType%" equ "Security" echo.正在清理 WHD 安全更新临时文件夹……
if "%UpdateType%" equ "NET35" echo.正在清理 Microsoft .NET Framework 3.5 更新临时文件夹……
if "%UpdateType%" equ "WAT" echo.正在清理 Windows 激活技术临时文件夹……
if "%UpdateType%" equ "Windows10" echo.正在清理 Windows 10 升级准备更新临时文件夹……
if "%UpdateType%" equ "WinPE" echo.正在清理 Windows PE 更新临时文件夹……
if "%UpdateType%" equ "WUSatisfy" echo.正在清理 Windows Update Satisfy 更新临时文件夹……
if "%UpdateType%" equ "ADLDS" echo.正在清理 Active Directory 轻型目录服务临时文件夹……
if "%UpdateType%" equ "FMApi" echo.正在清理文件管理 API 临时文件夹……
if "%UpdateType%" equ "Features" echo.正在清理 Windows 功能更新临时文件夹……
if "%UpdateType%" equ "VirtualPC" echo.正在清理 Microsoft Virtual PC 功能临时文件夹……
if "%UpdateType%" equ "WorkFolders" echo.正在清理适用于域环境的同步代理临时文件夹……

call :RemoveFolder "%Temp%\Updates"
echo.
echo.-------------------------------------------------------------------------------
if "%UpdateType%" equ "WUpdates" echo.####集成 Windows 更新已完成####################################################
if "%UpdateType%" equ "General" echo.####集成 WHD 常规更新已完成####################################################
if "%UpdateType%" equ "Hotfix" echo.####集成 WHD 热修复更新已完成##################################################
if "%UpdateType%" equ "Security" echo.####集成 WHD 安全更新已完成####################################################
if "%UpdateType%" equ "NET35" echo.####集成 Microsoft .NET Framework 3.5 更新已完成###############################
if "%UpdateType%" equ "WAT" echo.####集成 Windows 激活技术 ^(WAT^) 已完成#########################################
if "%UpdateType%" equ "Windows10" echo.####集成 Windows 10 升级准备更新已完成#########################################
if "%UpdateType%" equ "WinPE" echo.####集成 Windows PE 更新已完成#################################################
if "%UpdateType%" equ "WUSatisfy" echo.####集成 Windows Update Satisfy Update 已完成##################################
if "%UpdateType%" equ "ADLDS" echo.####集成 Active Directory 轻型目录服务功能#####################################
if "%UpdateType%" equ "FMApi" echo.####集成文件管理 API 功能已完成################################################
if "%UpdateType%" equ "Features" echo.####集成 Windows 功能更新已完成################################################
if "%UpdateType%" equ "VirtualPC" echo.####集成 Microsoft Virtual PC 功能已完成#######################################
if "%UpdateType%" equ "WorkFolders" echo.####集成适用于域环境的同步代理 ^(工作文件夹^) 已完成#############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Updates=
set UpdateType=
set IsW7SP1CRUSelected=

endlocal

:: 读取已更新的映像信息
if "%SelectedSourceOS%" equ "w10" (
	if "%ImageIndexNo%" equ "*" (
		call :GetImageIndexInfo "%InstallWim%", 1 >nul
		call :MountImageRegistry "%InstallMount%\1"
		for /f "tokens=3 delims= " %%z in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do (set /a ImageServicePackBuild=%%z)
		call :UnMountImageRegistry
	) else (
		call :GetImageIndexInfo "%InstallWim%", %ImageIndexNo% >nul
		call :MountImageRegistry "%InstallMount%"
		for /f "tokens=3 delims= " %%z in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do (set /a ImageServicePackBuild=%%z)
		call :UnMountImageRegistry
	)
)

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 安装媒介更新模块
::-------------------------------------------------------------------------------------------
:IntWindowsSetupMediaUpdates

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 更新 Windows 安装媒介
echo.===============================================================================
echo.
:: 获取启动映像索引体系结构
call :GetImageArchitecture "%BootWim%", 1 >nul

:: 设置 Install 安装文件夹路径
if "%ImageIndexNo%" equ "*" (
	set "InstallMount1=%InstallMount%"
	set "InstallMount=%InstallMount%\1"
)

echo.-------------------------------------------------------------------------------
echo.####正在开始更新 Windows 安装媒介##############################################
echo.-------------------------------------------------------------------------------
echo.
echo.正在获取 Windows 安装媒介语言设置……
echo.
for /f "tokens=* delims=" %%a in ('%DISM% /Get-WimInfo /WimFile:%BootWim% /Index:1 ^| findstr /i Default') do ( set ImageDefaultLanguage=%%a )
set ImageDefaultLanguage=%ImageDefaultLanguage:~1,-11%
echo.已找到 Windows 安装程序媒介语言 ：[%ImageDefaultLanguage%]
echo.
echo.正在复制 Windows 安装媒介更新文件到 ^<DVD^> 文件夹……

:: 创建目录布局
call :CreateFolder "%DVD%"
call :CreateFolder "%DVD%\boot"
call :CreateFolder "%DVD%\efi"
call :CreateFolder "%DVD%\sources"
call :CreateFolder "%DVD%\boot\%ImageDefaultLanguage%"
call :CreateFolder "%DVD%\boot\fonts"
call :CreateFolder "%DVD%\boot\resources"
call :CreateFolder "%DVD%\efi\boot"
call :CreateFolder "%DVD%\efi\microsoft"
call :CreateFolder "%DVD%\efi\microsoft\boot"
call :CreateFolder "%DVD%\efi\microsoft\boot\fonts"
call :CreateFolder "%DVD%\efi\microsoft\boot\resources"
call :CreateFolder "%DVD%\sources\%ImageDefaultLanguage%"
call :CreateFolder "%DVD%\sources\inf"

Copy /Y "%BootMount%\2\Windows\Boot\PCAT\bootmgr" "%DVD%\bootmgr" >nul
Copy /Y "%BootMount%\2\Windows\Boot\EFI\bootmgr.efi" "%DVD%\bootmgr.efi" >nul
Copy /Y "%BootMount%\2\setup.exe" "%DVD%\setup.exe" >nul
Copy /Y "%BootMount%\2\Windows\Boot\DVD\PCAT\bcd" "%DVD%\boot\bcd" >nul
Copy /Y "%BootMount%\2\Windows\Boot\DVD\PCAT\boot.sdi" "%DVD%\boot\boot.sdi" >nul
Copy /Y "%BootMount%\2\Windows\Boot\DVD\PCAT\%ImageDefaultLanguage%\bootfix.bin" "%DVD%\boot\bootfix.bin" >nul
Copy /Y "%BootMount%\2\Windows\System32\bootsect.exe" "%DVD%\boot\bootsect.exe" >nul
Copy /Y "%BootMount%\2\Windows\Boot\DVD\PCAT\etfsboot.com" "%DVD%\boot\etfsboot.com" >nul
Copy /Y "%BootMount%\2\Windows\Boot\PCAT\memtest.exe" "%DVD%\boot\memtest.exe" >nul
Copy /Y "%BootMount%\2\Windows\System32\%ImageDefaultLanguage%\bootsect.exe.mui" "%DVD%\boot\%ImageDefaultLanguage%\bootsect.exe.mui" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\chs_boot.ttf" "%DVD%\boot\fonts\chs_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\cht_boot.ttf" "%DVD%\boot\fonts\cht_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\jpn_boot.ttf" "%DVD%\boot\fonts\jpn_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\kor_boot.ttf" "%DVD%\boot\fonts\kor_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\malgunn_boot.ttf" "%DVD%\boot\fonts\malgunn_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\malgun_boot.ttf" "%DVD%\boot\fonts\malgun_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\meiryon_boot.ttf" "%DVD%\boot\fonts\meiryon_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\meiryo_boot.ttf" "%DVD%\boot\fonts\meiryo_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\msjhn_boot.ttf" "%DVD%\boot\fonts\msjhn_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\msjh_boot.ttf" "%DVD%\boot\fonts\msjh_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\msyhn_boot.ttf" "%DVD%\boot\fonts\msyhn_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\msyh_boot.ttf" "%DVD%\boot\fonts\msyh_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\segmono_boot.ttf" "%DVD%\boot\fonts\segmono_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\segoen_slboot.ttf" "%DVD%\boot\fonts\segoen_slboot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\segoe_slboot.ttf" "%DVD%\boot\fonts\segoe_slboot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\wgl4_boot.ttf" "%DVD%\boot\fonts\wgl4_boot.ttf" >nul
Copy /Y "%BootMount%\2\Windows\Boot\Resources\bootres.dll" "%DVD%\boot\resources\bootres.dll" >nul
rem "%DVD%\efi\boot\bootia32.efi" >nul
rem "%DVD%\efi\microsoft\boot\cdboot.efi" >nul
rem "%DVD%\efi\microsoft\boot\cdboot_noprompt.efi" >nul
Copy /Y "%BootMount%\2\Windows\Boot\DVD\EFI\%ImageDefaultLanguage%\efisys.bin" "%DVD%\efi\microsoft\boot\efisys.bin" >nul
Copy /Y "%BootMount%\2\Windows\Boot\DVD\EFI\%ImageDefaultLanguage%\efisys_noprompt.bin" "%DVD%\efi\microsoft\boot\efisys_noprompt.bin" >nul
Copy /Y "%BootMount%\2\Windows\Boot\EFI\memtest.efi" "%DVD%\efi\microsoft\boot\memtest.efi" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\chs_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\chs_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\cht_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\cht_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\jpn_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\jpn_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\kor_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\kor_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\malgunn_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\malgunn_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\malgun_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\malgun_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\meiryon_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\meiryon_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\meiryo_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\meiryo_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\msjhn_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\msjhn_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\msjh_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\msjh_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\msyhn_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\msyhn_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\msyh_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\msyh_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\segmono_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\segmono_boot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\segoen_slboot.ttf" "%DVD%\efi\microsoft\boot\fonts\segoen_slboot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\segoe_slboot.ttf" "%DVD%\efi\microsoft\boot\fonts\segoe_slboot.ttf" >nul
Copy /Y "%InstallMount%\Windows\Boot\Fonts\wgl4_boot.ttf" "%DVD%\efi\microsoft\boot\fonts\wgl4_boot.ttf" >nul
rem "%DVD%\efi\microsoft\boot\resources\bootres.dll" >nul
Copy /Y "%InstallMount%\Windows\apppatch\acres.dll" "%DVD%\sources\acres.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\actionqueue.dll" "%DVD%\sources\actionqueue.dll" >nul
rem "%DVD%\sources\adfscomp.dll" >nul
rem "%DVD%\sources\admtv3check.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\aeinv.dll" "%DVD%\sources\aeinv.dll" >nul
rem "%DVD%\sources\alert.gif" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-advapi32-l1-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-advapi32-l1-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-advapi32-l1-1-1.dll" "%DVD%\sources\api-ms-win-downlevel-advapi32-l1-1-1.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-advapi32-l2-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-advapi32-l2-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-advapi32-l2-1-1.dll" "%DVD%\sources\api-ms-win-downlevel-advapi32-l2-1-1.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-advapi32-l3-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-advapi32-l3-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-advapi32-l4-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-advapi32-l4-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-kernel32-l1-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-kernel32-l1-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-kernel32-l2-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-kernel32-l2-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-ole32-l1-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-ole32-l1-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-ole32-l1-1-1.dll" "%DVD%\sources\api-ms-win-downlevel-ole32-l1-1-1.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-shlwapi-l1-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-shlwapi-l1-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-shlwapi-l1-1-1.dll" "%DVD%\sources\api-ms-win-downlevel-shlwapi-l1-1-1.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-user32-l1-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-user32-l1-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-user32-l1-1-1.dll" "%DVD%\sources\api-ms-win-downlevel-user32-l1-1-1.dll" >nul
Copy /Y "%BootMount%\2\sources\api-ms-win-downlevel-version-l1-1-0.dll" "%DVD%\sources\api-ms-win-downlevel-version-l1-1-0.dll" >nul
Copy /Y "%BootMount%\2\sources\appcompat.xsl" "%DVD%\sources\appcompat.xsl" >nul
Copy /Y "%BootMount%\2\sources\appcompat_bidi.xsl" "%DVD%\sources\appcompat_bidi.xsl" >nul
rem "%DVD%\sources\appcompat_detailed.xsl" >nul
rem "%DVD%\sources\appcompat_detailed_bidi.xsl" >nul
Copy /Y "%BootMount%\2\sources\appcompat_detailed_bidi_txt.xsl" "%DVD%\sources\appcompat_detailed_bidi_txt.xsl" >nul
Copy /Y "%BootMount%\2\sources\appcompat_detailed_txt.xsl" "%DVD%\sources\appcompat_detailed_txt.xsl" >nul
Copy /Y "%BootMount%\2\sources\arunimg.dll" "%DVD%\sources\arunimg.dll" >nul
Copy /Y "%BootMount%\2\sources\arunres.dll" "%DVD%\sources\arunres.dll" >nul
Copy /Y "%BootMount%\2\sources\autorun.dll" "%DVD%\sources\autorun.dll" >nul
rem "%DVD%\sources\background_cli.bmp" >nul
rem "%DVD%\sources\cdplib.mof" >nul
rem "%DVD%\sources\cdplibuninstall.mof" >nul
rem "%DVD%\sources\clustercompliance.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\cmi2migxml.dll" "%DVD%\sources\cmi2migxml.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\cmifw.dll" "%DVD%\sources\cmifw.dll" >nul
Copy /Y "%BootMount%\2\sources\cmisetup.dll" "%DVD%\sources\cmisetup.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\compatctrl.dll" "%DVD%\sources\compatctrl.dll" >nul
Copy /Y "%BootMount%\2\sources\compatprovider.dll" "%DVD%\sources\compatprovider.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\compatresources.dll" "%DVD%\sources\compatresources.dll" >nul
Copy /Y "%BootMount%\2\sources\compliance.ini" "%DVD%\sources\compliance.ini" >nul
rem "%DVD%\sources\compres.dll" >nul
Copy /Y "%BootMount%\2\sources\cryptosetup.dll" "%DVD%\sources\cryptosetup.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\csiagent.dll" "%DVD%\sources\csiagent.dll" >nul
rem "%DVD%\sources\cversion.ini" >nul
rem "%DVD%\sources\db_msftproductionwindowssigningca.cer" >nul
Copy /Y "%InstallMount%\Windows\System32\devinv.dll" "%DVD%\sources\devinv.dll" >nul
Copy /Y "%BootMount%\2\sources\diager.dll" "%DVD%\sources\diager.dll" >nul
Copy /Y "%BootMount%\2\sources\diagnostic.dll" "%DVD%\sources\diagnostic.dll" >nul
Copy /Y "%BootMount%\2\sources\dism.exe" "%DVD%\sources\dism.exe" >nul
Copy /Y "%BootMount%\2\Windows\System32\dismapi.dll" "%DVD%\sources\dismapi.dll" >nul
Copy /Y "%BootMount%\2\sources\dismcore.dll" "%DVD%\sources\dismcore.dll" >nul
Copy /Y "%BootMount%\2\sources\dismcoreps.dll" "%DVD%\sources\dismcoreps.dll" >nul
Copy /Y "%BootMount%\2\sources\dismprov.dll" "%DVD%\sources\dismprov.dll" >nul
Copy /Y "%InstallMount%\Windows\apppatch\drvmain.sdb" "%DVD%\sources\drvmain.sdb" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\drvmain32.sdb" "%DVD%\sources\drvmain32.sdb" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\drvmain64.sdb" "%DVD%\sources\drvmain64.sdb" >nul
rem "%DVD%\sources\drvmainarm.sdb" >nul
Copy /Y "%BootMount%\2\sources\drvmgrtn.dll" "%DVD%\sources\drvmgrtn.dll" >nul
Copy /Y "%BootMount%\2\sources\du.dll" "%DVD%\sources\du.dll" >nul
Copy /Y "%InstallMount%\Windows\WinSxS\x86_microsoft-windows-servicingstack-net_31bf3856ad364e35_6.3.9600.17031_none_d358249e46914d92\firewallofflineapi.dll" "%DVD%\sources\firewallofflineapi.dll" >nul
Copy /Y "%BootMount%\2\sources\文件夹provider.dll" "%DVD%\sources\文件夹provider.dll" >nul
rem "%DVD%\sources\fveupg.dll" >nul
Copy /Y "%BootMount%\2\sources\hwcompat.dll" "%DVD%\sources\hwcompat.dll" >nul
Copy /Y "%BootMount%\2\sources\hwcompat.txt" "%DVD%\sources\hwcompat.txt" >nul
rem "%DVD%\sources\hwcompatPE.txt" >nul
Copy /Y "%BootMount%\2\sources\hwexclude.txt" "%DVD%\sources\hwexclude.txt" >nul
rem "%DVD%\sources\hwexcludePE.txt" >nul
rem "%DVD%\sources\hypervcomplcheck.dll" >nul
Copy /Y "%BootMount%\2\sources\idwbinfo.txt" "%DVD%\sources\idwbinfo.txt" >nul
rem "%DVD%\sources\iiscomp.dll" >nul
Copy /Y "%BootMount%\2\sources\imagingprovider.dll" "%DVD%\sources\imagingprovider.dll" >nul
Copy /Y "%BootMount%\2\sources\input.dll" "%DVD%\sources\input.dll" >nul
rem "%DVD%\sources\install.exe" >nul
Copy /Y "%InstallMount%\Windows\System32\oobe\installeventres.dll" "%DVD%\sources\installeventres.dll" >nul
rem "%DVD%\sources\installprep.exe" >nul
rem "%DVD%\sources\itgtupg.dll" >nul
Copy /Y "%BootMount%\2\sources\lang.ini" "%DVD%\sources\lang.ini" >nul
Copy /Y "%BootMount%\2\sources\locale.nls" "%DVD%\sources\locale.nls" >nul
Copy /Y "%BootMount%\2\sources\logprovider.dll" "%DVD%\sources\logprovider.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\luainstall.dll" "%DVD%\sources\luainstall.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\migapp.xml" "%DVD%\sources\migapp.xml" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\migcore.dll" "%DVD%\sources\migcore.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\mighost.exe" "%DVD%\sources\mighost.exe" >nul
Copy /Y "%InstallMount%\Windows\System32\migisol.dll" "%DVD%\sources\migisol.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\migres.dll" "%DVD%\sources\migres.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\migstore.dll" "%DVD%\sources\migstore.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\migsys.dll" "%DVD%\sources\migsys.dll" >nul
rem "%DVD%\sources\migtestplugin.dll" >nul
Copy /Y "%BootMount%\2\sources\msxml6.dll" "%DVD%\sources\msxml6.dll" >nul
Copy /Y "%BootMount%\2\sources\msxml6r.dll" "%DVD%\sources\msxml6r.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\mxeagent.dll" "%DVD%\sources\mxeagent.dll" >nul
Copy /Y "%BootMount%\2\sources\ndiscompl.dll" "%DVD%\sources\ndiscompl.dll" >nul
Copy /Y "%BootMount%\2\sources\nlsbres.dll" "%DVD%\sources\nlsbres.dll" >nul
Copy /Y "%BootMount%\2\sources\ntdsupg.dll" "%DVD%\sources\ntdsupg.dll" >nul
rem "%DVD%\sources\ntfrsupg.dll" >nul
rem "%DVD%\sources\nxquery.cat" >nul
rem "%DVD%\sources\nxquery.inf" >nul
rem "%DVD%\sources\nxquery.sys" >nul
Copy /Y "%BootMount%\2\sources\offline.xml" "%DVD%\sources\offline.xml" >nul
rem "%DVD%\sources\oscomps.woa.xml" >nul
rem "%DVD%\sources\oscomps.xml" >nul
rem "%DVD%\sources\osfilter.inf" >nul
rem "%DVD%\sources\outofbox_windows_db.bin" >nul
Copy /Y "%BootMount%\2\sources\pnpibs.dll" "%DVD%\sources\pnpibs.dll" >nul
rem "%DVD%\sources\postrollback.exe" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\queryappblock.exe" "%DVD%\sources\queryappblock.exe" >nul
rem "%DVD%\sources\quirks.ait" >nul
rem "%DVD%\sources\rdsupgcheck.dll" >nul
Copy /Y "%InstallMount%\Windows\PolicyDefinitions\reagent.admx" "%DVD%\sources\reagent.admx" >nul
Copy /Y "%BootMount%\2\sources\reagent.dll" "%DVD%\sources\reagent.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\Recovery\reagent.xml" "%DVD%\sources\reagent.xml" >nul
rem "%DVD%\sources\reportgen.dll" >nul
rem "%DVD%\sources\rmsupg.dll" >nul
Copy /Y "%BootMount%\2\sources\rollback.exe" "%DVD%\sources\rollback.exe" >nul
Copy /Y "%BootMount%\2\sources\schema.dat" "%DVD%\sources\schema.dat" >nul
Copy /Y "%BootMount%\2\sources\sdbapiu.dll" "%DVD%\sources\sdbapiu.dll" >nul
Copy /Y "%BootMount%\2\sources\segoeui.ttf" "%DVD%\sources\segoeui.ttf" >nul
Copy /Y "%BootMount%\2\sources\setup.exe" "%DVD%\sources\setup.exe" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\setupcompat.dll" "%DVD%\sources\setupcompat.dll" >nul
rem "%DVD%\sources\setuperror.exe" >nul
Copy /Y "%BootMount%\2\sources\setupplatform.cfg" "%DVD%\sources\setupplatform.cfg" >nul
Copy /Y "%BootMount%\2\sources\setupplatform.dll" "%DVD%\sources\setupplatform.dll" >nul
Copy /Y "%BootMount%\2\sources\setupplatform.exe" "%DVD%\sources\setupplatform.exe" >nul
rem "%DVD%\sources\setupresume.exe" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sfcn.dat" "%DVD%\sources\sfcn.dat" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sflcid.dat" "%DVD%\sources\sflcid.dat" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sflistw7.dat" "%DVD%\sources\sflistw7.dat" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sflistw8.dat" "%DVD%\sources\sflistw8.dat" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sflistw8.woa.dat" "%DVD%\sources\sflistw8.woa.dat" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sflistwb.dat" "%DVD%\sources\sflistwb.dat" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sflistwb.woa.dat" "%DVD%\sources\sflistwb.woa.dat" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sfpat.inf" "%DVD%\sources\sfpat.inf" >nul
rem "%DVD%\sources\sfpatpg.inf" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sfpatw7.inf" "%DVD%\sources\sfpatw7.inf" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sfpatw8.inf" "%DVD%\sources\sfpatw8.inf" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\sfpatwb.inf" "%DVD%\sources\sfpatwb.inf" >nul
Copy /Y "%BootMount%\2\sources\smiengine.dll" "%DVD%\sources\smiengine.dll" >nul
Copy /Y "%BootMount%\2\sources\spflvrnt.dll" "%DVD%\sources\spflvrnt.dll" >nul
Copy /Y "%BootMount%\2\sources\spprgrss.dll" "%DVD%\sources\spprgrss.dll" >nul
Copy /Y "%BootMount%\2\sources\spwizeng.dll" "%DVD%\sources\spwizeng.dll" >nul
Copy /Y "%BootMount%\2\sources\spwizimg.dll" "%DVD%\sources\spwizimg.dll" >nul
Copy /Y "%BootMount%\2\sources\spwizres.dll" "%DVD%\sources\spwizres.dll" >nul
Copy /Y "%BootMount%\2\sources\sqmapi.dll" "%DVD%\sources\sqmapi.dll" >nul
Copy /Y "%BootMount%\2\sources\ssshim.dll" "%DVD%\sources\ssshim.dll" >nul
Copy /Y "%InstallMount%\Windows\apppatch\sysmain.sdb" "%DVD%\sources\sysmain.sdb" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\sysmain32.sdb" "%DVD%\sources\sysmain32.sdb" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\sysmain64.sdb" "%DVD%\sources\sysmain64.sdb" >nul
rem "%DVD%\sources\telemetry.xsd" >nul
rem "%DVD%\sources\uddicomp.dll" >nul
Copy /Y "%BootMount%\2\sources\unattend.dll" "%DVD%\sources\unattend.dll" >nul
Copy /Y "%BootMount%\2\sources\unbcl.dll" "%DVD%\sources\unbcl.dll" >nul
rem "%DVD%\sources\upgcompat.inf" >nul" >nul
rem "%DVD%\sources\upgdriver.dll" >nul" >nul
Copy /Y "%BootMount%\2\sources\upgloader.dll" "%DVD%\sources\upgloader.dll" >nul
rem "%DVD%\sources\upgradeagent.dll" >nul
rem "%DVD%\sources\upgradeagent.xml" >nul
rem "%DVD%\sources\upgrade_bulk.xml" >nul
rem "%DVD%\sources\upgrade_data.xml" >nul
Copy /Y "%BootMount%\2\sources\upgrade_frmwrk.xml" "%DVD%\sources\upgrade_frmwrk.xml" >nul
Copy /Y "%BootMount%\2\sources\upgreport.dll" "%DVD%\sources\upgreport.dll" >nul
rem "%DVD%\sources\upgwow_bulk.xml" >nul
Copy /Y "%BootMount%\2\sources\uxlib.dll" "%DVD%\sources\uxlib.dll" >nul
Copy /Y "%BootMount%\2\sources\uxlibres.dll" "%DVD%\sources\uxlibres.dll" >nul
Copy /Y "%BootMount%\2\sources\vhdprovider.dll" "%DVD%\sources\vhdprovider.dll" >nul
Copy /Y "%BootMount%\2\sources\w32uiimg.dll" "%DVD%\sources\w32uiimg.dll" >nul
Copy /Y "%BootMount%\2\sources\w32uires.dll" "%DVD%\sources\w32uires.dll" >nul
Copy /Y "%BootMount%\2\sources\warning.gif" "%DVD%\sources\warning.gif" >nul
Copy /Y "%BootMount%\2\sources\wdsclient.dll" "%DVD%\sources\wdsclient.dll" >nul
Copy /Y "%BootMount%\2\sources\wdsclientapi.dll" "%DVD%\sources\wdsclientapi.dll" >nul
Copy /Y "%BootMount%\2\sources\wdscore.dll" "%DVD%\sources\wdscore.dll" >nul
Copy /Y "%BootMount%\2\sources\wdscsl.dll" "%DVD%\sources\wdscsl.dll" >nul
Copy /Y "%BootMount%\2\sources\wdsimage.dll" "%DVD%\sources\wdsimage.dll" >nul
Copy /Y "%BootMount%\2\sources\wdstptc.dll" "%DVD%\sources\wdstptc.dll" >nul
rem "%DVD%\sources\wdsupgcompl.dll" >nul
Copy /Y "%BootMount%\2\sources\wdsutil.dll" "%DVD%\sources\wdsutil.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\wica.dll" "%DVD%\sources\wica.dll" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\wica.ini" "%DVD%\sources\wica.ini" >nul
rem "%DVD%\sources\wicadevicefilters.xml" >nul
Copy /Y "%InstallMount%\Windows\System32\CompatTel\wicainventory.exe" "%DVD%\sources\wicainventory.exe" >nul
rem "%DVD%\sources\wicatel.dll" >nul
Copy /Y "%BootMount%\2\sources\wimprovider.dll" "%DVD%\sources\wimprovider.dll" >nul
Copy /Y "%BootMount%\2\sources\win32ui.dll" "%DVD%\sources\win32ui.dll" >nul
Copy /Y "%BootMount%\2\sources\winsetup.dll" "%DVD%\sources\winsetup.dll" >nul
Copy /Y "%InstallMount%\Windows\apppatch\%ImageDefaultLanguage%\acres.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\acres.dll.mui" >nul
Copy /Y "%InstallMount%\Windows\System32\%ImageDefaultLanguage%\actionqueue.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\actionqueue.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\arunres.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\arunres.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\cmisetup.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\cmisetup.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\compatctrl.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\compatprovider.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\compatprovider.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\compatresources.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\compres.dll.mui" >nul
Copy /Y "%InstallMount%\Windows\Help\%ImageDefaultLanguage%\credits.rtf" "%DVD%\sources\%ImageDefaultLanguage%\credits.rtf" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\dism.exe.mui" "%DVD%\sources\%ImageDefaultLanguage%\dism.exe.mui" >nul
Copy /Y "%InstallMount%\Windows\System32\%ImageDefaultLanguage%\dismapi.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\dismapi.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\dismcore.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\dismcore.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\dismprov.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\dismprov.dll.mui" >nul
Copy /Y "%InstallMount%\Windows\System32\%ImageDefaultLanguage%\erofflps.txt" "%DVD%\sources\%ImageDefaultLanguage%\erofflps.txt" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\文件夹provider.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\文件夹provider.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\imagingprovider.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\imagingprovider.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\input.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\input.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\install.exe.mui" >nul
Copy /Y "%InstallMount%\Windows\System32\oobe\%ImageDefaultLanguage%\installeventres.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\installeventres.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\installprep.exe.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\logprovider.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\logprovider.dll.mui" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\%ImageDefaultLanguage%\migcore.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\migcore.dll.mui" >nul
Copy /Y "%InstallMount%\Windows\System32\migwiz\%ImageDefaultLanguage%\migres.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\migres.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\msxml6r.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\msxml6r.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\nlsbres.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\nlsbres.dll.mui" >nul
Copy /Y "%InstallMount%\Windows\System32\oobe\%ImageDefaultLanguage%\oobe_help_opt_in_details.rtf" "%DVD%\sources\%ImageDefaultLanguage%\oobe_help_opt_in_details.rtf" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\pnpibs.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\pnpibs.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\postrollback.exe.mui" >nul
Copy /Y "%InstallMount%\Windows\System32\oobe\%ImageDefaultLanguage%\privacy.rtf" "%DVD%\sources\%ImageDefaultLanguage%\privacy.rtf" >nul
Copy /Y "%InstallMount%\Windows\PolicyDefinitions\%ImageDefaultLanguage%\reagent.adml" "%DVD%\sources\%ImageDefaultLanguage%\reagent.adml" >nul
Copy /Y "%InstallMount%\Windows\System32\%ImageDefaultLanguage%\reagent.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\reagent.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\rollback.exe.mui" "%DVD%\sources\%ImageDefaultLanguage%\rollback.exe.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\setup.exe.mui" "%DVD%\sources\%ImageDefaultLanguage%\setup.exe.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\setupcompat.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\setuperror.exe.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\setupplatform.exe.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\setupresume.exe.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\setup_help_upgrade_or_custom.rtf" "%DVD%\sources\%ImageDefaultLanguage%\setup_help_upgrade_or_custom.rtf" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\setup_help_whattokeep.rtf" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\smiengine.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\smiengine.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\spwizres.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\spwizres.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\upgdriver.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\upgloader.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\upgloader.dll.mui" >nul
rem "%DVD%\sources\%ImageDefaultLanguage%\upgreport.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\uxlibres.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\uxlibres.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\vhdprovider.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\vhdprovider.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\vofflps.rtf" "%DVD%\sources\%ImageDefaultLanguage%\vofflps.rtf" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\w32uires.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\w32uires.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\wdsclient.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\wdsclient.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\wdsimage.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\wdsimage.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\wimprovider.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\wimprovider.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\%ImageDefaultLanguage%\winsetup.dll.mui" "%DVD%\sources\%ImageDefaultLanguage%\winsetup.dll.mui" >nul
Copy /Y "%BootMount%\2\sources\inf\setup.cfg" "%DVD%\sources\inf\setup.cfg" >nul
echo.
echo.-------------------------------------------------------------------------------
echo.####更新 Windows 安装媒介已完成################################################
echo.-------------------------------------------------------------------------------
echo.
echo.===============================================================================
echo.
pause

if "%ImageIndexNo%" equ "*" (
	set "InstallMount=%InstallMount1%"
	set InstallMount1=
)

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 8.1 Media Center 通用激活令牌到安装映像模块
::-------------------------------------------------------------------------------------------
:IntWMCGActTokens

if "%IsDialogsEnabled%" equ "Yes" (
	cls
	echo.===============================================================================
	echo.           MSMG 工具箱 - 集成 Windows 8.1 Media Center 通用激活令牌
	echo.===============================================================================
	echo.
	echo.
	echo.                            信                 息
	echo.                            =====================
	echo.
	echo.  Windows 8.1 Media Center 通用激活令牌是从未激活的 Windows 8.0 专业版^(含 
	echo.  Media Center^)操作系统通过 Windows 应用商店升级方法升级到的 Windows 8.1 专业
	echo.  版^(含 Media Center^)操作系统中解压的通用令牌数据文件。
	echo.
	echo.  由于 Windows 8.1 专业版操作系统不接受 Windows 8.0 专业版^(含 Media Center^)或
	echo.  Media Center 附加密钥来安装操作系统，因此这些通用令牌有助于使 Windows 安装程
	echo.  序接受并安装 Windows 8.0 专业版^(含 Media Center^)或 Media Center 附加密钥以进
	echo.  行安装。
	echo.
	echo.  之后，可以通过在线或电话激活的方式直接激活已安装的操作系统。
	echo.
	echo.
	echo.  若要关闭此警告对话框，请在工具 -^> 选项菜单中选择禁用对话框
	echo.
	echo.===============================================================================
	echo.
	choice /C:YN /N /M "你想要继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :IntegrateMenu
)

setlocal

cls
echo.===============================================================================
echo.           MSMG 工具箱 - 集成 Windows 8.1 Media Center 通用激活令牌
echo.===============================================================================
echo.

:: 检查多重索引维护模式是否已启用
if "%ImageIndexNo%" equ "*" (
	echo.当多重索引维护模式已启用时，此功能不可用……
	echo.
	echo.请使用单一的索引重新选择源文件……
	goto :Stop
)

:: 获取安装映像索引体系结构
call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 检查所选择的源操作系统是否是 Windows 8.1 专业版（含 WMC）
%Imagex% /Info "%InstallWim%" %ImageIndexNo% | findstr /c:"<EDITIONID>ProfessionalWMC</EDITIONID>" >nul
if errorlevel 1 (
	echo.选择的源不是 Windows 8.1 专业版 ^(含 WMC^)……
	echo.
	echo.请使用 Windows 8.1 专业版 ^(含 WMC^) 操作系统作为源文件……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 8.1 Media Center 通用激活令牌#########################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 8.1 Media Center 通用激活令牌#############################
echo.-------------------------------------------------------------------------------
call :ApplyImage "%WMCGActTokens%", 1, "%InstallMount%"
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 8.1 Media Center 通用激活令牌已完成###########################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 8.1 预激活数据模块
::-------------------------------------------------------------------------------------------
:IntPreActTokens

if "%IsDialogsEnabled%" equ "Yes" (
	cls
	echo.===============================================================================
	echo.                  MSMG 工具箱 - 集成 Windows 8.1 预激活数据
	echo.===============================================================================
	echo.
	echo. MSMG 工具箱将允许你将系统激活详细信息集成到 Windows 安装光盘映像中，以执行系
	echo. 统自动激活，而无需联机激活或电话激活。
	echo.
	echo. 注意：当对系统硬件进行任何更改时，此激活状态都将会丢失。
	echo.
	echo.
	echo.
	echo. 要        求：
	echo. -------------
	echo. 1^) Windows 产品密钥
	echo.
	echo. 2^) 来自 Windows 激活系统驱动器的最新预激活令牌文件
	echo.
	echo.    - “data.dat”来自“<%SytemDrive%\Windows\System32\spp\store>”文件夹
	echo.    - “tokens.dat”来自“<%SytemDrive%\Windows\System32\spp\store>”文件夹
	echo.    - “cache.dat”来自“<%SytemDrive%\Windows\System32\spp\store>”文件夹
	echo.
	echo.===============================================================================
	echo.
	choice /C:YN /N /M "你想要继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :IntegrateMenu
)

setlocal

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 集成 Windows 8.1 预激活数据
echo.===============================================================================
echo.
:: 检查多重索引维护模式是否已启用
if "%ImageIndexNo%" equ "*" (
	echo.当多重索引维护模式已启用时，此功能不可用……
	echo.
	echo.请使用单一的索引重新选择源文件……
	goto :Stop
)

:: 设置 Windows 预激活详细信息文件夹路径
set "PreActTokens=%PreActTokens%\%SelectedSourceOS%\%ImageArchitecture%"

:: 获取安装映像索引体系结构
call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 检查 Windows 预激活令牌数据文件是否存在
if not exist "%PreActTokens%\data.dat" if not exist "%PreActTokens%\cache.dat" if not exist "%PreActTokens%\tokens.dat" (
	echo.Windows 预激活令牌数据文件文件夹 ^<Packs\PreActTokens\%SelectedSourceOS%\%ImageArchitecture%^> 是空的……
	echo.
	choice /C:YN /N /M "你想要从系统文件夹复制激活文件吗？ [是‘Y’/否‘N’] ："
	if errorlevel 2 (
		echo.
		echo.请复制预激活令牌文件到相应的文件夹……
		goto :Stop
	)
	if errorlevel 1 (
		echo.
		echo.正在从 ^<System32\Spp\store\2.0^> 复制预激活令牌文件
		Xcopy /O /H /R /K /Y "%SystemRoot%\System32\spp\store\2.0\data.dat" %PreActTokens% >nul
		Xcopy /O /H /R /K /Y "%SystemRoot%\System32\spp\store\2.0\tokens.dat" %PreActTokens% >nul		
		Xcopy /O /H /R /K /Y "%SystemRoot%\System32\spp\store\2.0\cache\cache.dat" %PreActTokens% >nul
	)
)

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 集成 Windows 8.1 预激活数据
echo.===============================================================================
echo.
echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 8.1 预激活数据########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage% 
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 Windows 8.1 激活产品密钥详细信息##################################
echo.-------------------------------------------------------------------------------
echo.
set /p ProductKey=请输入产品密钥（含‘-’）：
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 8.1 预激活数据############################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在集成 Windows 8.1 产品密钥 [%ProductKey%]……
echo.-------------------------------------------------------------------------------
%DISM% /Image:"%InstallMount%" /Set-ProductKey:%ProductKey%
echo.
echo.-------------------------------------------------------------------------------
echo.正在集成 Windows 8.1 预激活令牌文件……
echo.-------------------------------------------------------------------------------
echo.
echo.正在复制 Windows 8.1 预激活令牌文件……
Xcopy /O /H /R /K /Y %PreActTokens%\tokens.dat "%InstallMount%\Windows\System32\spp\store\2.0"
Xcopy /O /H /R /K /Y %PreActTokens%\data.dat "%InstallMount%\Windows\System32\spp\store\2.0"
Xcopy /O /H /R /K /Y %PreActTokens%\cache.dat "%InstallMount%\Windows\System32\spp\store\2.0\cache"
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 8.1 预激活数据已完成##########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set PreActTokens=
set ProductKey=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成终端服务器修补程序模块
::-------------------------------------------------------------------------------------------
:IntCustomTerminalServer

setlocal

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 集成 Microsoft 终端服务器修补程序
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 根据所选择的源操作系统设置终端服务器修补程序
set "CustomTerminalServer=%CustomTerminalServer%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查 Microsoft 终端服务器修补程序包文件是否存在
if not exist "%CustomTerminalServer%\termsrv.dll" (
	echo.Microsoft 终端服务器修补程序文件“termsrv.dll”没有找到……
	echo.
	echo.请复制上述文件到 ^<Custom\TerminalServer\%SelectedSourceOS%\%ImageArchitecture%^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft 终端服务器修补程序##################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft 终端服务器修补程序######################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		
		echo.正在复制已修补的 Microsoft 终端服务器 [termsrv.dll] 文件……
		echo.
		%XCopy% %CustomTerminalServer%\*.* "%InstallMount%\%%i\Windows\System32"
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####正在合并 Microsoft 终端服务器修补程序注册表设置############################
		echo.-------------------------------------------------------------------------------
		echo.
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"

		echo.正在将注册表设置合并到映像注册表……	
		Reg add "HKLM\TK_SYSTEM\ControlSet001\Control\Terminal Server" /v "fDenyTSConnections" /t REG_DWORD /d "0" /f >nul
		Reg add "HKLM\TK_SYSTEM\ControlSet001\Control\Terminal Server" /v "fSingleSessionPerUser" /t REG_DWORD /d "0" /f >nul
		
		echo.正在卸载映像注册表……		
		call :UnMountImageRegistry
		echo.
	)
) else (
	echo.
	echo.正在复制已修补的 Microsoft 终端服务器 [termsrv.dll] 文件……
	echo.
	%XCopy% %CustomTerminalServer%\*.* "%InstallMount%\Windows\System32"
	echo.
	echo.-------------------------------------------------------------------------------
	echo.####正在合并 Microsoft 终端服务器修补程序注册表设置############################
	echo.-------------------------------------------------------------------------------
	echo.
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"

	echo.正在将注册表设置合并到映像注册表……	
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Control\Terminal Server" /v "fDenyTSConnections" /t REG_DWORD /d "0" /f >nul
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Control\Terminal Server" /v "fSingleSessionPerUser" /t REG_DWORD /d "0" /f >nul

	echo.正在卸载映像注册表……	
	call :UnMountImageRegistry
	echo.
)
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft 终端服务器修补程序已完成####################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set CustomTerminalServer=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成自定义 UxTheme 补丁模块
::-------------------------------------------------------------------------------------------
:IntCustomUxTheme

setlocal

cls
echo.===============================================================================
echo.                    MSMG 工具箱 - 集成自定义 UxTheme 补丁
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 根据所选择的源操作系统设置自定义 UxTheme 补丁包文件路径
set "CustomUxTheme=%CustomUxTheme%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查自定义 UxTheme 补丁包文件是否存在
if "%SelectedSourceOS%" equ "w7" (
	for %%i in (themeservice.dll, themeui.dll, uxtheme.dll) do (
		if not exist "%CustomUxTheme%\%%i" (
			echo.自定义 UxTheme 补丁文件“%%i”没有找到……
			echo.
			echo.请复制上述文件到 ^<Custom\UxTheme\%SelectedSourceOS%\%ImageArchitecture%^> 文件夹……
			goto :Stop
		)
	)
)

:: 检查自定义 UxTheme 补丁包文件是否存在
if "%SelectedSourceOS%" neq "w7" (
	for %%i in (themeui.dll, UXInit.dll, uxtheme.dll) do (
		if not exist "%CustomUxTheme%\%%i" (
			echo.自定义 UxTheme 补丁文件“%%i”没有找到……
			echo.
			echo.请复制上述文件到 ^<Custom\UxTheme\%SelectedSourceOS%\%ImageArchitecture%^> 文件夹……
			goto :Stop
		)
	)
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成自定义 UxTheme 补丁############################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成自定义 UxTheme 补丁################################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.正在复制自定义 UxTheme 补丁文件……
		echo.
		%XCopy% %CustomUxTheme%\*.* "%InstallMount%\%%i\Windows\System32"
	)
) else (
	echo.
	echo.正在复制自定义 UxTheme 补丁文件……
	echo.
	%XCopy% %CustomUxTheme%\*.* "%InstallMount%\Windows\System32"
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成自定义 UxTheme 补丁已完成##############################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set CustomUxTheme=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成自定义 Windows 恢复映像模块
::-------------------------------------------------------------------------------------------
:IntCustomRecoveryImage

setlocal

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 集成自定义 Windows 恢复映像
echo.===============================================================================
echo.
:: 检查多重索引维护模式是否已启用
if "%ImageIndexNo%" equ "*" (
	echo.当多重索引维护模式已启用时，此功能不可用……
	echo.
	echo.请使用单一的索引重新选择源文件……
	goto :Stop
)

:: 检查源 Windows 恢复映像是否已被选择
if "%IsRecoveryImageSelected%" equ "No" (
	echo.Windows 恢复映像尚未选择……
	echo.
	echo.请在选择源文件时选择 Windows 恢复映像……
	goto :Stop	
)

:: 检查所选择的源操作系统是否是 Windows Thin PC 操作系统
if "%SelectedSourceOS%" equ "w7" if "%ImageEdition%" equ "Embedded" (
	echo.Windows Thin PC 操作系统不受支持……
	echo.
	echo.请使用 Windows 7.x/8.1/10 的客户端/服务器版操作系统作为源……
	goto :Stop
)

:: 获取恢复映像索引体系结构
call :GetImageArchitecture "%InstallMount%\%WinReWim%", 1 >nul

:: 根据所选源操作系统设置自定义 Windows 恢复映像文件路径
set "RecoveryImage=%RecoveryImage%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查自定义 Windows 恢复映像文件是否存在
if not exist "%RecoveryImage%\winre.wim" (
	echo.自定义 Windows 恢复映像文件“winre.wim”没有找到……
	echo.
	echo.请复制上述文件到 ^<Custom\RecoveryImage\%SelectedSourceOS%\%ImageArchitecture%^> 文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始集成自定义 Windows 恢复映像########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：WinRE.wim
echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在卸载已安装的 Windows 恢复映像##########################################
echo.-------------------------------------------------------------------------------
call :UnMountImage "%WinReMount%", "Discard"
echo.-------------------------------------------------------------------------------
echo.####正在集成自定义 Windows 恢复映像############################################
echo.-------------------------------------------------------------------------------
echo.
echo.正在复制自定义 Windows 恢复环境 ^(WinRE^) 映像……
%XCopy% %RecoveryImage%\*.* "%InstallMount%\Windows\System32\Recovery" >nul
echo.
echo.-------------------------------------------------------------------------------
echo.####正在重新安装 Windows 恢复映像##############################################
echo.-------------------------------------------------------------------------------
call :MountImage "%InstallMount%\%WinReWim%", 1, "%WinReMount%"
echo.-------------------------------------------------------------------------------
echo.####集成自定义 Windows 恢复映像已完成##########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set RecoveryImage=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成自定义默认用户帐户图片模块
::-------------------------------------------------------------------------------------------
:IntUAP

setlocal

cls
echo.===============================================================================
echo.                   MSMG 工具箱 - 集成自定义默认用户帐户图片
echo.===============================================================================
echo.

:: 根据所选择的源操作系统设置自定义默认用户帐户图片路径
set "UAP=%UAP%\%SelectedSourceOS%"

:: 检查自定义默认用户帐户图片包是否存在
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" neq "Server" (
	if not exist "%UAP%\user.bmp" (
		echo.自定义默认用户帐户图片包文件“user.bmp”没有找到……
		echo.
		echo.请复制上述文件到 ^<Packs\UAP\%SelectedSourceOS%^> 文件夹……
		goto :Stop
	)
)

:: 检查自定义默认用户帐户图片包是否存在
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Server" (
	if not exist "%UAP%\user.bmp" (
		echo.自定义默认用户帐户图片包文件“user.bmp”没有找到……
		echo.
		echo.请复制上述文件到 ^<Packs\UAP\%SelectedSourceOS%^> 文件夹……
		goto :Stop
	)
)

:: 检查自定义默认用户帐户图片包是否存在
if "%SelectedSourceOS%" equ "w81" (
	for %%i in (guest.bmp, guest.png, user.bmp, user.png, user-40.png, user-200.png) do (
		if not exist "%UAP%\%%i" (
			echo.自定义默认用户帐户图片包文件“%%i”没有找到……
			echo.
			echo.请复制上述文件到 ^<Packs\UAP\%SelectedSourceOS%^> 文件夹……
			goto :Stop
		)
	)
)

:: 检查自定义默认用户帐户图片包是否存在
if "%SelectedSourceOS%" equ "w10" (
	for %%i in (guest.bmp, guest.png, user.bmp, user.png, user-32.png, user-40.png, user-48.png, user-192.png, user-200.png) do (
		if not exist "%UAP%\%%i" (
			echo.自定义默认用户帐户图片包文件“%%i”没有找到……
			echo.
			echo.请复制上述文件到 ^<Packs\UAP\%SelectedSourceOS%^> 文件夹……
			goto :Stop
		)
	)
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成自定义默认用户帐户图片#########################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成自定义默认用户帐户图片#############################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		:: 检查所选择的源操作系统是否是 Windows Server 2008 R2 Core 版本
		if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Server Core" (
			echo.此功能不可用于 Windows Server 2008 R2 Core 版本操作系统……
			echo.
		)

		if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" neq "Server Core" (
			echo.正在复制自定义默认用户帐户图片文件……
			echo.
			if "%ImageInstallationType%" neq "Server" %XCopy% %UAP%\*.* "%InstallMount%\%%i\ProgramData\Microsoft\User Account Pictures"
			if "%ImageInstallationType%" equ "Server" %XCopy% %UAP%\user.bmp "%InstallMount%\%%i\ProgramData\Microsoft\User Account Pictures"
		) 
		if "%SelectedSourceOS%" neq "w7" (
			echo.正在复制自定义默认用户帐户图片文件……
			echo.
			%XCopy% %UAP%\*.* "%InstallMount%\%%i\ProgramData\Microsoft\User Account Pictures"
		)
	)
) else (
	echo.
	:: 检查所选择的源操作系统是否是 Windows Server 2008 R2 Core 版本
	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Server Core" (
		echo.此功能不可用于 Windows Server 2008 R2 Core 版本操作系统……
		echo.
		echo.请选择 Windows Server 2008 R2 非核心版本源操作系统……
		goto :Stop
	)

	if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" neq "Server Core" (
		echo.正在复制自定义默认用户帐户图片文件……
		echo.
		if "%ImageInstallationType%" neq "Server" %XCopy% %UAP%\*.* "%InstallMount%\ProgramData\Microsoft\User Account Pictures"
		if "%ImageInstallationType%" equ "Server" %XCopy% %UAP%\user.bmp "%InstallMount%\ProgramData\Microsoft\User Account Pictures"
	) 
	if "%SelectedSourceOS%" neq "w7" (
		echo.正在复制自定义默认用户帐户图片文件……
		echo.
		%XCopy% %UAP%\*.* "%InstallMount%\ProgramData\Microsoft\User Account Pictures"
	)
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成自定义默认用户帐户图片已完成###########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set UAP=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成自定义系统文件模块
::-------------------------------------------------------------------------------------------
:IntCustomFiles

setlocal

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 集成自定义系统文件
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 根据所选择的源操作系统设置自定义系统文件路径
set "CustomFiles=%CustomFiles%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查自定义系统文件包文件是否存在
for /f %%i in ('dir /b /s /a:-d "%CustomFiles%\*.*" 2^>nul ^| find /v /c ""') do (
	if "%%i" equ "0" (
		echo.自定义系统文件包文件夹是空的……
		echo.
		echo.请复制上述文件到 ^<Custom\Files\%SelectedSourceOS%\%ImageArchitecture%^> 文件夹……
		goto :Stop
	)
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成自定义系统文件#################################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成自定义系统文件#####################################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.正在复制自定义系统文件……
		echo.
		%XCopy% %CustomFiles%\*.* "%InstallMount%\%%i"
	)
) else (
	echo.
	echo.正在复制自定义系统文件……
	echo.
	%XCopy% %CustomFiles%\*.* "%InstallMount%"
)
echo.
echo.-------------------------------------------------------------------------------
echo.####集成自定义系统文件已完成###################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set CustomFiles=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Microsoft Win32 计算器 Metro 皮肤模块
::-------------------------------------------------------------------------------------------
:IntWin32CalcMetroSkin

setlocal

cls
echo.===============================================================================
echo.             MSMG 工具箱 - 集成 Microsoft Win32 计算器 Metro 皮肤
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

set "Skins=%Skins%\Win32Calc"

:: 检查 Microsoft Win32 计算器 Metro 皮肤包文件是否存在
if not exist "%Skins%\Win32Calc.exe.res" (
	echo.Microsoft Win32 计算器 Metro 皮肤包文件“Win32Calc.exe.res”没有找到……
	echo.
	echo.请复制上述文件到 ^<Packs\Skins\Win32Calc^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Microsoft Win32 计算器 Metro 皮肤#############################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Microsoft Win32 计算器 Metro 皮肤#################################
echo.-------------------------------------------------------------------------------

copy /y %ResourceHacker% %Temp% >nul

if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.正在复制 Microsoft Win32 计算器文件到临时文件夹……
		if "%ImageArchitecture%" equ "x86" copy "%InstallMount%\%%i\Windows\System32\Win32Calc.exe" "%Temp%\Win32Calc_x.exe" >nul
		if "%ImageArchitecture%" equ "x64" (
			copy "%InstallMount%\%%i\Windows\System32\Win32Calc.exe" "%Temp%\Win32Calc64_x.exe" >nul
			copy "%InstallMount%\%%i\Windows\SysWOW64\Win32Calc.exe" "%Temp%\Win32Calc32_x.exe" >nul
		)

		echo.
		echo.正在应用 Microsoft Win32 计算器 Metro 皮肤到 [Win32Calc.exe] 文件……
		if "%ImageArchitecture%" equ "x86" (		
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\Win32Calc_x.exe", "%Temp%\Win32Calc.exe", "%Skins%\Win32Calc.exe.res" ,,,
			call :RemoveFile "%Temp%\Win32Calc_x.exe"
		)

		if "%ImageArchitecture%" equ "x64" (
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\Win32Calc32_x.exe", "%Temp%\Win32Calc32.exe", "%Skins%\Win32Calc.exe.res" ,,,
			call :RemoveFile "%Temp%\Win32Calc32_x.exe"
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\Win32Calc64_x.exe", "%Temp%\Win32Calc64.exe", "%Skins%\Win32Calc.exe.res" ,,,
			call :RemoveFile "%Temp%\Win32Calc64_x.exe"
		)

		echo.
		echo.正在复制已修复的 Microsoft Win32 计算器文件……
		if "%ImageArchitecture%" equ "x86" move /y "%Temp%\Win32Calc.exe" "%InstallMount%\%%i\Windows\System32\Win32Calc.exe" >nul
		if "%ImageArchitecture%" equ "x64" (
			move /y "%Temp%\Win32Calc64.exe" "%InstallMount%\%%i\Windows\System32\Win32Calc.exe" >nul
			move /y "%Temp%\Win32Calc32.exe" "%InstallMount%\%%i\Windows\SysWOW64\Win32Calc.exe" >nul	
		)
	)
) else (
	echo.
	echo.正在复制 Microsoft Win32 计算器文件到临时文件夹……
	if "%ImageArchitecture%" equ "x86" copy "%InstallMount%\Windows\System32\Win32Calc.exe" "%Temp%\Win32Calc_x.exe" >nul
	if "%ImageArchitecture%" equ "x64" (
		copy "%InstallMount%\Windows\System32\Win32Calc.exe" "%Temp%\Win32Calc64_x.exe" >nul
		copy "%InstallMount%\Windows\SysWOW64\Win32Calc.exe" "%Temp%\Win32Calc32_x.exe" >nul
	)

	echo.
	echo.正在应用 Microsoft Win32 计算器 Metro 皮肤到 [Win32Calc.exe] 文件……
	if "%ImageArchitecture%" equ "x86" (		
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\Win32Calc_x.exe", "%Temp%\Win32Calc.exe", "%Skins%\Win32Calc.exe.res" ,,,
		call :RemoveFile "%Temp%\Win32Calc_x.exe"
	)

	if "%ImageArchitecture%" equ "x64" (
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\Win32Calc32_x.exe", "%Temp%\Win32Calc32.exe", "%Skins%\Win32Calc.exe.res" ,,,
		call :RemoveFile "%Temp%\Win32Calc32_x.exe"
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\Win32Calc64_x.exe", "%Temp%\Win32Calc64.exe", "%Skins%\Win32Calc.exe.res" ,,,
		call :RemoveFile "%Temp%\Win32Calc64_x.exe"
	)

	echo.
	echo.正在复制已修复的 Microsoft Win32 计算器文件……
	if "%ImageArchitecture%" equ "x86" move /y "%Temp%\Win32Calc.exe" "%InstallMount%\Windows\System32\Win32Calc.exe" >nul
	if "%ImageArchitecture%" equ "x64" (
		move /y "%Temp%\Win32Calc64.exe" "%InstallMount%\Windows\System32\Win32Calc.exe" >nul
		move /y "%Temp%\Win32Calc32.exe" "%InstallMount%\Windows\SysWOW64\Win32Calc.exe" >nul	
	)
)

call :RemoveFile "%Temp%\ResourceHacker.exe"
call :RemoveFile "%Temp%\ResourceHacker.ini"
call :RemoveFile "%Temp%\ResourceHacker.log"
echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Microsoft Win32 计算器 Metro 皮肤已完成###############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Skins=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows 照片查看器 Metro 皮肤模块
::-------------------------------------------------------------------------------------------
:IntWPVMetroSkin

setlocal

cls
echo.===============================================================================
echo.               MSMG 工具箱 - 集成 Windows 照片查看器 Metro 皮肤
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

set "Skins=%Skins%\PhotoViewer"

:: 检查 Windows 照片查看器 Metro 皮肤包文件是否存在
for %%i in (PhotoViewer.dll.res, photowiz.dll.res) do (
	if not exist "%Skins%\%%i" (
		echo.Windows 照片查看器 Metro 皮肤包文件“%%i”没有找到……
		echo.
		echo.请复制上述文件到 ^<Packs\Skins\PhotoViewer^> 文件夹……
		goto :Stop
	)
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows 照片查看器 Metro 皮肤#################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows 照片查看器 Metro 皮肤#####################################
echo.-------------------------------------------------------------------------------

copy /y %ResourceHacker% %Temp% >nul

if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.正在复制 Windows 照片查看器文件到临时文件夹……
		if "%ImageArchitecture%" equ "x86" (
			copy "%InstallMount%\%%i\Program Files\Windows 照片查看器\PhotoViewer.dll" "%Temp%\PhotoViewer_x.dll" >nul
			copy "%InstallMount%\%%i\Windows\System32\photowiz.dll" "%Temp%\photowiz_x.dll" >nul
		)
		if "%ImageArchitecture%" equ "x64" (
			copy "%InstallMount%\%%i\Program Files\Windows 照片查看器\PhotoViewer.dll" "%Temp%\PhotoViewer64_x.dll" >nul
			copy "%InstallMount%\%%i\Program Files (x86)\Windows 照片查看器\PhotoViewer.dll" "%Temp%\PhotoViewer32_x.dll" >nul
			copy "%InstallMount%\%%i\Windows\System32\photowiz.dll" "%Temp%\photowiz64_x.dll" >nul
			copy "%InstallMount%\%%i\Windows\SysWOW64\photowiz.dll" "%Temp%\photowiz32_x.dll" >nul
		)

		echo.
		if "%ImageArchitecture%" equ "x86" (		
			echo.正在应用 Windows 照片查看器 Metro 皮肤到 [PhotoViewer.dll] 文件……
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\PhotoViewer_x.dll", "%Temp%\PhotoViewer.dll", "%Skins%\PhotoViewer.dll.res" ,,,
			call :RemoveFile "%Temp%\PhotoViewer_x.dll"
			echo.
			echo.正在应用 Windows 照片查看器 Metro 皮肤到 [photowiz.dll] 文件……
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\photowiz_x.dll", "%Temp%\photowiz.dll", "%Skins%\photowiz.dll.res" ,,,
			call :RemoveFile "%Temp%\photowiz_x.dll"
		)

		if "%ImageArchitecture%" equ "x64" (
			echo.正在应用 Windows 照片查看器 Metro 皮肤到 [PhotoViewer.dll] 文件……
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\PhotoViewer32_x.dll", "%Temp%\PhotoViewer32.dll", "%Skins%\PhotoViewer.dll.res" ,,,
			call :RemoveFile "%Temp%\PhotoViewer32_x.dll"
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\PhotoViewer64_x.dll", "%Temp%\PhotoViewer64.dll", "%Skins%\PhotoViewer.dll.res" ,,,
			call :RemoveFile "%Temp%\PhotoViewer64_x.dll"
			echo.
			echo.正在应用 Windows 照片查看器 Metro 皮肤到 [photowiz.dll] 文件……
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\photowiz32_x.dll", "%Temp%\photowiz32.dll", "%Skins%\photowiz.dll.res" ,,,
			call :RemoveFile "%Temp%\photowiz32_x.dll"
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\photowiz64_x.dll", "%Temp%\photowiz64.dll", "%Skins%\photowiz.dll.res" ,,,
			call :RemoveFile "%Temp%\photowiz64_x.dll"
		)

		echo.
		echo.正在复制已修补的 Windows 照片查看器文件……
		if "%ImageArchitecture%" equ "x86" (
			move /y "%Temp%\PhotoViewer.dll" "%InstallMount%\%%i\Program Files\Windows 照片查看器\PhotoViewer.dll" >nul
			move /y "%Temp%\photowiz.dll" "%InstallMount%\%%i\Windows\System32\photowiz.dll" >nul
		)
		if "%ImageArchitecture%" equ "x64" (
			move /y "%Temp%\PhotoViewer64.dll" "%InstallMount%\%%i\Program Files\Windows 照片查看器\PhotoViewer.dll" >nul
			move /y "%Temp%\PhotoViewer32.dll" "%InstallMount%\%%i\Program Files (x86)\Windows 照片查看器\PhotoViewer.dll" >nul
			move /y "%Temp%\photowiz64.dll" "%InstallMount%\%%i\Windows\System32\photowiz.dll" >nul
			move /y "%Temp%\photowiz32.dll" "%InstallMount%\%%i\Windows\SysWOW64\photowiz.dll" >nul	
		)
	)
) else (
	echo.
	echo.正在复制 Windows 照片查看器文件到临时文件夹……
	if "%ImageArchitecture%" equ "x86" (
		copy "%InstallMount%\Program Files\Windows 照片查看器\PhotoViewer.dll" "%Temp%\PhotoViewer_x.dll" >nul
		copy "%InstallMount%\Windows\System32\photowiz.dll" "%Temp%\photowiz_x.dll" >nul
	)
	if "%ImageArchitecture%" equ "x64" (
		copy "%InstallMount%\Program Files\Windows 照片查看器\PhotoViewer.dll" "%Temp%\PhotoViewer64_x.dll" >nul
		copy "%InstallMount%\Program Files (x86)\Windows 照片查看器\PhotoViewer.dll" "%Temp%\PhotoViewer32_x.dll" >nul
		copy "%InstallMount%\Windows\System32\photowiz.dll" "%Temp%\photowiz64_x.dll" >nul
		copy "%InstallMount%\Windows\SysWOW64\photowiz.dll" "%Temp%\photowiz32_x.dll" >nul
	)

	echo.
	if "%ImageArchitecture%" equ "x86" (		
		echo.正在应用 Windows 照片查看器 Metro 皮肤到 [PhotoViewer.dll] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\PhotoViewer_x.dll", "%Temp%\PhotoViewer.dll", "%Skins%\PhotoViewer.dll.res" ,,,
		call :RemoveFile "%Temp%\PhotoViewer_x.dll"
		echo.
		echo.正在应用 Windows 照片查看器 Metro 皮肤到 [photowiz.dll] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\photowiz_x.dll", "%Temp%\photowiz.dll", "%Skins%\photowiz.dll.res" ,,,
		call :RemoveFile "%Temp%\photowiz_x.dll"
	)

	if "%ImageArchitecture%" equ "x64" (
		echo.正在应用 Windows 照片查看器 Metro 皮肤到 [PhotoViewer.dll] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\PhotoViewer32_x.dll", "%Temp%\PhotoViewer32.dll", "%Skins%\PhotoViewer.dll.res" ,,,
		call :RemoveFile "%Temp%\PhotoViewer32_x.dll"
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\PhotoViewer64_x.dll", "%Temp%\PhotoViewer64.dll", "%Skins%\PhotoViewer.dll.res" ,,,
		call :RemoveFile "%Temp%\PhotoViewer64_x.dll"
		echo.
		echo.正在应用 Windows 照片查看器 Metro 皮肤到 [photowiz.dll] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\photowiz32_x.dll", "%Temp%\photowiz32.dll", "%Skins%\photowiz.dll.res" ,,,
		call :RemoveFile "%Temp%\photowiz32_x.dll"
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\photowiz64_x.dll", "%Temp%\photowiz64.dll", "%Skins%\photowiz.dll.res" ,,,
		call :RemoveFile "%Temp%\photowiz64_x.dll"
	)

	echo.
	echo.正在复制已修补的 Windows 照片查看器文件……
	if "%ImageArchitecture%" equ "x86" (
		move /y "%Temp%\PhotoViewer.dll" "%InstallMount%\Program Files\Windows 照片查看器\PhotoViewer.dll" >nul
		move /y "%Temp%\photowiz.dll" "%InstallMount%\Windows\System32\photowiz.dll" >nul
	)
	if "%ImageArchitecture%" equ "x64" (
		move /y "%Temp%\PhotoViewer64.dll" "%InstallMount%\Program Files\Windows 照片查看器\PhotoViewer.dll" >nul
		move /y "%Temp%\PhotoViewer32.dll" "%InstallMount%\Program Files (x86)\Windows 照片查看器\PhotoViewer.dll" >nul
		move /y "%Temp%\photowiz64.dll" "%InstallMount%\Windows\System32\photowiz.dll" >nul
		move /y "%Temp%\photowiz32.dll" "%InstallMount%\Windows\SysWOW64\photowiz.dll" >nul	
	)
)

call :RemoveFile "%Temp%\ResourceHacker.exe"
call :RemoveFile "%Temp%\ResourceHacker.ini"
call :RemoveFile "%Temp%\ResourceHacker.log"

echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Windows 照片查看器 Metro 皮肤已完成###################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Skins=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 集成 Windows Media Player Metro 皮肤模块
::-------------------------------------------------------------------------------------------
:IntWMPMetroSkin

setlocal

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 集成 Windows Media Player Metro 皮肤
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

set "Skins=%Skins%\MediaPlayer"

:: 检查 Windows Media Player Metro 皮肤包文件是否存在
for %%i in (setup_wm.exe.res, wmpconfig.exe.res, wmplayer.exe.res, wmploc.dll.res, wmpshare.exe.res, WMPSideShowGadget.exe.res) do (
	if not exist "%Skins%\%%i" (
		echo.Windows Media Player Metro 皮肤包文件“%%i”没有找到……
		echo.
		echo.请复制上述文件到 ^<Packs\Skins\MediaPlayer^> 文件夹……
		goto :Stop
	)
)

echo.-------------------------------------------------------------------------------
echo.####正在开始集成 Windows Media Player Metro 皮肤###############################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在集成 Windows Media Player Metro 皮肤###################################
echo.-------------------------------------------------------------------------------

copy /y %ResourceHacker% %Temp% >nul

if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.正在复制 Windows Media Player 文件到临时文件夹……
		if "%ImageArchitecture%" equ "x86" (
			copy "%InstallMount%\%%i\Program Files\Windows Media Player\setup_wm.exe" "%Temp%\setup_wm_x.exe" >nul
			copy "%InstallMount%\%%i\Program Files\Windows Media Player\wmpconfig.exe" "%Temp%\wmpconfig_x.exe" >nul
			copy "%InstallMount%\%%i\Program Files\Windows Media Player\wmplayer.exe" "%Temp%\wmplayer_x.exe" >nul
			copy "%InstallMount%\%%i\Program Files\Windows Media Player\wmpshare.exe" "%Temp%\wmpshare_x.exe" >nul
			if exist "%InstallMount%\%%i\Program Files\Windows Media Player\WMPSideShowGadget.exe" copy "%InstallMount%\%%i\Program Files\Windows Media Player\WMPSideShowGadget.exe" "%Temp%\WMPSideShowGadget_x.exe" >nul
			copy "%InstallMount%\%%i\Windows\System32\wmploc.dll" "%Temp%\wmploc_x.dll" >nul
		)
		if "%ImageArchitecture%" equ "x64" (
			copy "%InstallMount%\%%i\Program Files\Windows Media Player\setup_wm.exe" "%Temp%\setup_wm_x.exe" >nul
			copy "%InstallMount%\%%i\Program Files\Windows Media Player\wmpconfig.exe" "%Temp%\wmpconfig_x.exe" >nul
			copy "%InstallMount%\%%i\Program Files\Windows Media Player\wmplayer.exe" "%Temp%\wmplayer_x.exe" >nul
			copy "%InstallMount%\%%i\Program Files\Windows Media Player\wmpshare.exe" "%Temp%\wmpshare_x.exe" >nul
			if exist "%InstallMount%\%%i\Program Files\Windows Media Player\WMPSideShowGadget.exe" copy "%InstallMount%\%%i\Program Files\Windows Media Player\WMPSideShowGadget.exe" "%Temp%\WMPSideShowGadget_x.exe" >nul
			copy "%InstallMount%\%%i\Windows\System32\wmploc.dll" "%Temp%\wmploc64_x.dll" >nul
			copy "%InstallMount%\%%i\Windows\SysWOW64\wmploc.dll" "%Temp%\wmploc32_x.dll" >nul		
		)

		echo.		
		echo.正在应用 Windows Media Player Metro 皮肤到 [setup_wm.exe] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\setup_wm_x.exe", "%Temp%\setup_wm.exe", "%Skins%\setup_wm.exe.res" ,,,
		call :RemoveFile "%Temp%\setup_wm_x.exe"		
		echo.正在应用 Windows Media Player Metro 皮肤到 [wmpconfig.exe] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmpconfig_x.exe", "%Temp%\wmpconfig.exe", "%Skins%\wmpconfig.exe.res" ,,,
		call :RemoveFile "%Temp%\wmpconfig_x.exe"
		echo.正在应用 Windows Media Player Metro 皮肤到 [wmplayer.exe] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmplayer_x.exe", "%Temp%\wmplayer.exe", "%Skins%\wmplayer.exe.res" ,,,
		call :RemoveFile "%Temp%\wmplayer_x.exe"		
		echo.正在应用 Windows Media Player Metro 皮肤到 [wmpshare.exe] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmpshare_x.exe", "%Temp%\wmpshare.exe", "%Skins%\wmpshare.exe.res" ,,,
		call :RemoveFile "%Temp%\wmpshare_x.exe"
		
		if exist "%Temp%\WMPSideShowGadget_x.exe" (
			echo.正在应用 Windows Media Player Metro 皮肤到 [WMPSideShowGadget.exe] 文件……
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\WMPSideShowGadget_x.exe", "%Temp%\WMPSideShowGadget.exe", "%Skins%\WMPSideShowGadget.exe.res" ,,,
			call :RemoveFile "%Temp%\WMPSideShowGadget_x.exe"
		)
		
		if "%ImageArchitecture%" equ "x86" (
			echo.正在应用 Windows Media Player Metro 皮肤到 [wmploc.dll] 文件……
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmploc_x.dll", "%Temp%\wmploc.dll", "%Skins%\wmploc.dll.res" ,,,
			call :RemoveFile "%Temp%\wmploc_x.dll"
		)

		if "%ImageArchitecture%" equ "x64" (
			echo.正在应用 Windows Media Player Metro 皮肤到 [wmploc.dll] 文件……
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmploc32_x.dll", "%Temp%\wmploc32.dll", "%Skins%\wmploc.dll.res" ,,,
			call :RemoveFile "%Temp%\wmploc32_x.dll"
			"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmploc64_x.dll", "%Temp%\wmploc64.dll", "%Skins%\wmploc.dll.res" ,,,
			call :RemoveFile "%Temp%\wmploc64_x.dll"
		)

		echo.
		echo.正在复制已修补的 Windows Media Player 文件……
		move /y "%Temp%\setup_wm.exe" "%InstallMount%\%%i\Program Files\Windows Media Player\setup_wm.exe" >nul
		move /y "%Temp%\wmpconfig.exe" "%InstallMount%\%%i\Program Files\Windows Media Player\wmpconfig.exe" >nul
		move /y "%Temp%\wmplayer.exe" "%InstallMount%\%%i\Program Files\Windows Media Player\wmplayer.exe" >nul
		move /y "%Temp%\wmpshare.exe" "%InstallMount%\%%i\Program Files\Windows Media Player\wmpshare.exe" >nul
		if exist "%Temp%\WMPSideShowGadget.exe" move /y "%Temp%\WMPSideShowGadget.exe" "%InstallMount%\%%i\Program Files\Windows Media Player\WMPSideShowGadget.exe" >nul
		if "%ImageArchitecture%" equ "x86" move /y "%Temp%\wmploc.dll" "%InstallMount%\%%i\Windows\System32\wmploc.dll" >nul
		if "%ImageArchitecture%" equ "x64" move /y "%Temp%\wmploc64.dll" "%InstallMount%\%%i\Windows\System32\wmploc.dll" >nul
		if "%ImageArchitecture%" equ "x64" move /y "%Temp%\wmploc32.dll" "%InstallMount%\%%i\Windows\SysWOW64\wmploc.dll" >nul
	)
) else (
	echo.
	echo.正在复制 Windows Media Player 文件到临时文件夹……
	if "%ImageArchitecture%" equ "x86" (
		copy "%InstallMount%\Program Files\Windows Media Player\setup_wm.exe" "%Temp%\setup_wm_x.exe" >nul
		copy "%InstallMount%\Program Files\Windows Media Player\wmpconfig.exe" "%Temp%\wmpconfig_x.exe" >nul
		copy "%InstallMount%\Program Files\Windows Media Player\wmplayer.exe" "%Temp%\wmplayer_x.exe" >nul
		copy "%InstallMount%\Program Files\Windows Media Player\wmpshare.exe" "%Temp%\wmpshare_x.exe" >nul
		if exist "%InstallMount%\Program Files\Windows Media Player\WMPSideShowGadget.exe" copy "%InstallMount%\Program Files\Windows Media Player\WMPSideShowGadget.exe" "%Temp%\WMPSideShowGadget_x.exe" >nul
		copy "%InstallMount%\Windows\System32\wmploc.dll" "%Temp%\wmploc_x.dll" >nul
	)
	if "%ImageArchitecture%" equ "x64" (
		copy "%InstallMount%\Program Files\Windows Media Player\setup_wm.exe" "%Temp%\setup_wm_x.exe" >nul
		copy "%InstallMount%\Program Files\Windows Media Player\wmpconfig.exe" "%Temp%\wmpconfig_x.exe" >nul
		copy "%InstallMount%\Program Files\Windows Media Player\wmplayer.exe" "%Temp%\wmplayer_x.exe" >nul
		copy "%InstallMount%\Program Files\Windows Media Player\wmpshare.exe" "%Temp%\wmpshare_x.exe" >nul
		if exist "%InstallMount%\Program Files\Windows Media Player\WMPSideShowGadget.exe" copy "%InstallMount%\Program Files\Windows Media Player\WMPSideShowGadget.exe" "%Temp%\WMPSideShowGadget_x.exe" >nul
		copy "%InstallMount%\Windows\System32\wmploc.dll" "%Temp%\wmploc64_x.dll" >nul
		copy "%InstallMount%\Windows\SysWOW64\wmploc.dll" "%Temp%\wmploc32_x.dll" >nul		
	)

	echo.		
	echo.正在应用 Windows Media Player Metro 皮肤到 [setup_wm.exe] 文件……
	"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\setup_wm_x.exe", "%Temp%\setup_wm.exe", "%Skins%\setup_wm.exe.res" ,,,
	call :RemoveFile "%Temp%\setup_wm_x.exe"		
	echo.正在应用 Windows Media Player Metro 皮肤到 [wmpconfig.exe] 文件……
	"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmpconfig_x.exe", "%Temp%\wmpconfig.exe", "%Skins%\wmpconfig.exe.res" ,,,
	call :RemoveFile "%Temp%\wmpconfig_x.exe"
	echo.正在应用 Windows Media Player Metro 皮肤到 [wmplayer.exe] 文件……
	"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmplayer_x.exe", "%Temp%\wmplayer.exe", "%Skins%\wmplayer.exe.res" ,,,
	call :RemoveFile "%Temp%\wmplayer_x.exe"		
	echo.正在应用 Windows Media Player Metro 皮肤到 [wmpshare.exe] 文件……
	"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmpshare_x.exe", "%Temp%\wmpshare.exe", "%Skins%\wmpshare.exe.res" ,,,
	call :RemoveFile "%Temp%\wmpshare_x.exe"
	
	if exist "%Temp%\WMPSideShowGadget_x.exe" (
		echo.正在应用 Windows Media Player Metro 皮肤到 [WMPSideShowGadget.exe] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\WMPSideShowGadget_x.exe", "%Temp%\WMPSideShowGadget.exe", "%Skins%\WMPSideShowGadget.exe.res" ,,,
		call :RemoveFile "%Temp%\WMPSideShowGadget_x.exe"
	)
	
	if "%ImageArchitecture%" equ "x86" (
		echo.正在应用 Windows Media Player Metro 皮肤到 [wmploc.dll] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmploc_x.dll", "%Temp%\wmploc.dll", "%Skins%\wmploc.dll.res" ,,,
		call :RemoveFile "%Temp%\wmploc_x.dll"
	)

	if "%ImageArchitecture%" equ "x64" (
		echo.正在应用 Windows Media Player Metro 皮肤到 [wmploc.dll] 文件……
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmploc32_x.dll", "%Temp%\wmploc32.dll", "%Skins%\wmploc.dll.res" ,,,
		call :RemoveFile "%Temp%\wmploc32_x.dll"
		"%Temp%\ResourceHacker.exe" -addoverwrite "%Temp%\wmploc64_x.dll", "%Temp%\wmploc64.dll", "%Skins%\wmploc.dll.res" ,,,
		call :RemoveFile "%Temp%\wmploc64_x.dll"
	)

	echo.
	echo.正在复制已修补的 Windows Media Player 文件……
	move /y "%Temp%\setup_wm.exe" "%InstallMount%\Program Files\Windows Media Player\setup_wm.exe" >nul
	move /y "%Temp%\wmpconfig.exe" "%InstallMount%\Program Files\Windows Media Player\wmpconfig.exe" >nul
	move /y "%Temp%\wmplayer.exe" "%InstallMount%\Program Files\Windows Media Player\wmplayer.exe" >nul
	move /y "%Temp%\wmpshare.exe" "%InstallMount%\Program Files\Windows Media Player\wmpshare.exe" >nul
	if exist "%Temp%\WMPSideShowGadget.exe" move /y "%Temp%\WMPSideShowGadget.exe" "%InstallMount%\Program Files\Windows Media Player\WMPSideShowGadget.exe" >nul
	if "%ImageArchitecture%" equ "x86" move /y "%Temp%\wmploc.dll" "%InstallMount%\Windows\System32\wmploc.dll" >nul
	if "%ImageArchitecture%" equ "x64" move /y "%Temp%\wmploc64.dll" "%InstallMount%\Windows\System32\wmploc.dll" >nul
	if "%ImageArchitecture%" equ "x64" move /y "%Temp%\wmploc32.dll" "%InstallMount%\Windows\SysWOW64\wmploc.dll" >nul
)

call :RemoveFile "%Temp%\ResourceHacker.exe"
call :RemoveFile "%Temp%\ResourceHacker.ini"
call :RemoveFile "%Temp%\ResourceHacker.log"

echo.
echo.-------------------------------------------------------------------------------
echo.####集成 Windows Media Player Metro 皮肤已完成#################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Skins=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 移除 Windows 组件菜单模块
::-------------------------------------------------------------------------------------------
:RemoveWindowsComponentsMenu

setlocal
set Component=

cls
echo.===============================================================================
echo.                       MSMG 工具箱 - 移除 Windows 组件
echo.===============================================================================
echo.

:: 检查所选择的源操作系统是否是 Windows 10 v1809 客户端版本非刷新版映像
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageServicePackBuild%" neq "1" (
	echo.工具箱组件删除仅适用于以下源操作系统映像……
	echo.
	echo.Windows 10 v1809 ^(10.0.17763.1^) 源操作系统。
	goto :Stop	
)

:: 检查所选择的源操作系统是否是 Windows 10 v1903 客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "18362" if "%ImageServicePackBuild%" lss "418" (
	echo.工具箱组件删除仅适用于以下源操作系统映像……
	echo.
	echo.Windows 10 v1903 ^(10.0.18362.418^) 源操作系统。
	goto :Stop	
)

:: 检查所选择的源操作系统是否是 Windows 10 v1909 客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "18363" if "%ImageServicePackBuild%" lss "418" (
	echo.工具箱组件删除仅适用于以下源操作系统映像……
	echo.
	echo.Windows 10 v1909 ^(10.0.18363.418^) 源操作系统。
	goto :Stop	
)

:: 检查所选择的源操作系统是否是 Windows 10 v2004 客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "19041" if "%ImageServicePackBuild%" lss "208" (
	echo.工具箱组件删除仅适用于以下源操作系统映像……
	echo.
	echo.Windows 10 v2004 ^(10.0.19041.208^) 源操作系统。
	goto :Stop	
)

:: 检查所选择的源操作系统是否是 Windows 10 v2009 客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "19042" if "%ImageServicePackBuild%" lss "208" (
	echo.工具箱组件删除仅适用于以下源操作系统映像……
	echo.
	echo.Windows 10 v2009 ^(10.0.19042.208^) 源操作系统。
	goto :Stop	
)

:: 移除 Windows 10 v1809/v1903/v1909/v2004/v2009 客户端版本
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "19042" (
	cls
	echo.===============================================================================
	echo.                     MSMG 工具箱 - 移除 Windows 组件菜单
	echo.===============================================================================
	echo.
	echo.  [1]  Internet
	echo.
	echo.  [2]  多 媒 体
	echo.
	echo.  [3]  隐    私
	echo.
	echo.  [4]  远程处理
	echo.
	echo.  [5]  系    统
	echo.
	echo.  [6]  系统应用
	echo.
	echo.  [7]  Windows 应用
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:1234567X /N /M "请输入你的选项 ："
	if errorlevel 8 goto :RemoveMenu
	if errorlevel 7 goto :RemoveWindowsAppsMenu
	if errorlevel 6 goto :RemoveSystemAppsMenu
	if errorlevel 5 goto :RemoveSystemMenu
	if errorlevel 4 goto :RemoveRemotingMenu
	if errorlevel 3 goto :RemovePrivacyMenu
	if errorlevel 2 goto :RemoveMultimediaMenu
	if errorlevel 1 goto :RemoveInternetMenu
)

:RemoveInternetMenu
:: 移除 Windows 10 v1809/v1903/v1909/v2004/v2009 客户端版本 Internet 菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "19042" (
	cls
	echo.===============================================================================
	echo.                    MSMG 工具箱 - 移除 Internet 组件菜单
	echo.===============================================================================
	echo.
	echo.  [1]  适用于 Windows 的 Adobe Flash
	echo.
	echo.  [2]  Edge Chromium 浏览器
	echo.
	echo.  [3]  Internet Explorer
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [A]  所有 Internet 组件
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123AX /N /M "请输入你的选项 ："
	if errorlevel 5 goto :RemoveWindowsComponentsMenu
	if errorlevel 4 set "Component=InternetComponents"
	if errorlevel 3 set "Component=InternetExplorer"
	if errorlevel 2 set "Component=EdgeChromium"
	if errorlevel 1 set "Component=AdobeFlashForWindows"

	goto :RemoveWindowsComponents
)

:RemoveMultimediaMenu
:: 移除 Windows 10 v1809/v1903/v1909/v2004/v2009 客户端版本多媒体菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "19042" (
	cls
	echo.===============================================================================
	echo.                      MSMG 工具箱 - 移除多媒体组件菜单
	echo.===============================================================================
	echo.
	echo.  [1]  首次登录动画
	echo.  [2]  游戏浏览器 ^| 需要 Microsoft 游戏
	echo.  [3]  截图工具
	echo.  [4]  语音识别 ^| 需要 Cortana
	echo.  [5]  Windows Media Player
	echo.  [6]  Windows 照片查看器
	echo.  [7]  Windows 系统评估工具 ^| 需要 Microsoft 游戏
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [A]  所有多媒体组件
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:1234567AX /N /M "请输入你的选项 ："
	if errorlevel 9 goto :RemoveWindowsComponentsMenu
	if errorlevel 8 set "Component=MultimediaComponents"
	if errorlevel 7 set "Component=WinSAT"
	if errorlevel 6 set "Component=WindowsPhotoViewer"
	if errorlevel 5 set "Component=WindowsMediaPlayer"
	if errorlevel 4 set "Component=SpeechRecognition"
	if errorlevel 3 set "Component=SnippingTool"
	if errorlevel 2 set "Component=GameExplorer"
	if errorlevel 1 set "Component=FirstLogonAnimation"

	goto :RemoveWindowsComponents
)

:RemovePrivacyMenu
:: 移除 Windows 10 v1809/v1903/v1909/v2004/v2009 客户端版本隐私菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "19042" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除隐私组件菜单
	echo.===============================================================================
	echo.
	echo.  [A]  分配的访问权限
	echo.  [B]  客户体验改善计划 ^(CEIP^)
	echo.  [C]  人脸识别
	echo.  [D]  内核调试 ^| 依赖于：Windows 错误报告
	echo.  [E]  定位服务
	echo.  [F]  图片密码
	echo.  [G]  Pin 登录支持
	echo.  [H]  统一遥测客户端 ^(Asimov^) ^| 依赖于：Windows 错误报告
	echo.  [I]  WiFi Network Manager ^(WiFi 感知^)
	if "%ImageBuild%" equ "17763" echo.  [J]  Windows 错误报告
	if "%ImageBuild%" geq "18362" if "%ImageBuild%" leq "18363" echo.  [J]  Windows 错误报告 ^| 需要全新体验应用程序
	if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" echo.  [J]  Windows 错误报告
	echo.  [K]  Windows 会员中心
	echo.
	echo.
	echo.  [1]  所有隐私组件
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJK1X /N /M "请输入你的选项 ："
	if errorlevel 13 goto :RemoveWindowsComponentsMenu
	if errorlevel 12 set "Component=PrivacyComponents"
	if errorlevel 11 set "Component=WindowsInsiderHub"
	if errorlevel 10 set "Component=WindowsErrorReporting"
	if errorlevel 9  set "Component=WiFiNetworkManager"
	if errorlevel 8  set "Component=UnifiedTelemetryClient"
	if errorlevel 7  set "Component=PinEnrollment"
	if errorlevel 6  set "Component=PicturePassword"
	if errorlevel 5  set "Component=LocationService"
	if errorlevel 4  set "Component=KernelDebugging"
	if errorlevel 3  set "Component=FaceRecognition"
	if errorlevel 2  set "Component=CEIP_SQM"
	if errorlevel 1  set "Component=AssignedAccess"

	goto :RemoveWindowsComponents
)

:RemoveRemotingMenu
:: 移除 Windows 10 v1809/v1903/v1909/v2004/v2009 客户端版本远程处理菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "19042" (
	cls
	echo.===============================================================================
	echo.                     MSMG 工具箱 - 移除远程处理组件菜单
	echo.===============================================================================
	echo.
	echo.  [1]  家庭组
	echo.
	echo.  [2]  MultiPoint Connector
	echo.
	echo.  [3]  远程协助
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [A]  所有远程处理组件
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:123AX /N /M "请输入你的选项 ："
	if errorlevel 5 goto :RemoveWindowsComponentsMenu
	if errorlevel 4 set "Component=RemotingComponents"
	if errorlevel 3 set "Component=RemoteAssistance"
	if errorlevel 2 set "Component=MultiPointConnector"
	if errorlevel 1 set "Component=HomeGroup"

	goto :RemoveWindowsComponents
)

:RemoveSystemMenu
:: 移除 Windows 10 v1809/v1903/v1909/v2004/v2009 客户端版本系统菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "19042" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除系统组件菜单
	echo.===============================================================================
	echo.  [A]  设备锁定 ^(嵌入式体验^)
	echo.  [B]  轻松访问主题
	echo.  [C]  轻松传送
	echo.  [D]  文件历史记录
	echo.  [E]  手动安装程序 ^(就地升级^)
	echo.  [F]  画图
	echo.  [G]  安全中心 ^| 依赖于：Windows Defender
	echo.  [H]  步骤记录器
	echo.  [I]  系统恢复
	echo.  [J]  Windows 备份
	echo.  [K]  适用于 Linux 的 Windows 子系统
	echo.  [L]  Windows To Go
	echo.  [M]  写字板
	echo.
	echo.
	echo.  [1]  所有高级组件
	echo.
	echo.  [X]  返回
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLM1X /N /M "请输入你的选项 ："
	if errorlevel 15 goto :RemoveWindowsComponentsMenu
	if errorlevel 14 set "Component=SystemComponents"
	if errorlevel 13 set "Component=Wordpad"
	if errorlevel 12 set "Component=WindowsToGo"
	if errorlevel 11 set "Component=WindowsSubsystemForLinux"
	if errorlevel 10 set "Component=WindowsBackup"
	if errorlevel 9  set "Component=SystemRestore"
	if errorlevel 8  set "Component=StepsRecorder"
	if errorlevel 7  set "Component=SecurityCenter"
	if errorlevel 6  set "Component=Paint"
	if errorlevel 5  set "Component=ManualSetup"
	if errorlevel 4  set "Component=FileHistory"
	if errorlevel 3  set "Component=EasyTransfer"
	if errorlevel 2  set "Component=EaseOfAccessThemes"
	if errorlevel 1  set "Component=DeviceLockdown"

	goto :RemoveWindowsComponents
)

:RemoveSystemAppsMenu
:: 移除 Windows 10 v1809 客户端版本 Enterprise LTSC 2019 客户端版本系统应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" equ "EnterpriseS" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除系统应用菜单
	echo.===============================================================================
	echo.  [A]  指定访问锁定应用 ^| 依赖于：分配的访问权限
	echo.  [B]  Azure Active Directory AppX 代理插件
	echo.  [C]  生物注册应用
	echo.  [D]  Camera Barcode Scanner
	echo.  [E]  Content Delivery Manager ^| 需要全新体验应用程序
	echo.  [F]  Cortana、开始菜单和设置搜索应用 ^| 依赖于：语音识别
	echo.  [G]  Edge 开发者工具客户端
	echo.  [H]  目视控制应用
	echo.  [I]  文件资源管理器应用
	echo.  [J]  锁屏应用
	echo.  [K]  地图控件
	echo.  [L]  Narrator QuickStart
	echo.  [M]  家长控制应用
	echo.  [N]  人脉栏
	echo.  [O]  快速助手应用
	echo.  [P]  零售演示内容
	echo.  [Q]  设置同步
	echo.  [R]  Skype ORTC
	echo.  [S]  Smart Screen ^| 依赖于：Windows Defender
	echo.  [T]  Win32 Web View 主机
	echo.  [U]  Windows Defender 应用
	echo.  [V]  Windows 混合现实
	echo.  [W]  Windows 阅读器 ^(PDF^)
	echo.  [X]  Xbox Game Callable UI
	echo.
	echo.  [1]   所有系统应用
	echo.  [2]  返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWX12 /N /M "请输入你的选项 ："
	if errorlevel 26 goto :RemoveWindowsComponentsMenu
	if errorlevel 25 set "Component=SystemApps"
	if errorlevel 24 set "Component=XboxGameCallableUI"
	if errorlevel 23 set "Component=WindowsReaderPDF"
	if errorlevel 22 set "Component=WindowsMixedReality"
	if errorlevel 21 set "Component=WindowsDefender"
	if errorlevel 20 set "Component=Win32WebViewHost"
	if errorlevel 19 set "Component=SmartScreen"
	if errorlevel 18 set "Component=SkypeORTC"
	if errorlevel 17 set "Component=SettingSync"
	if errorlevel 16 set "Component=RetailDemoContent"
	if errorlevel 15 set "Component=QuickAssist"
	if errorlevel 14 set "Component=PeopleExperienceHost"
	if errorlevel 13 set "Component=ParentalControls"
	if errorlevel 12 set "Component=NarratorQuickStart"
	if errorlevel 11 set "Component=MapControl"
	if errorlevel 10 set "Component=LockApp"
	if errorlevel 9  set "Component=FileExplorer"
	if errorlevel 8  set "Component=ECApp"
	if errorlevel 7  set "Component=EdgeDevToolsClient"
	if errorlevel 6  set "Component=Cortana"
	if errorlevel 5  set "Component=ContentDeliveryManager"
	if errorlevel 4  set "Component=CBSPreview"
	if errorlevel 3  set "Component=BioEnrollment"
	if errorlevel 2  set "Component=AADBrokerPlugin"
	if errorlevel 1  set "Component=AssignedAccessLockApp"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v1809 客户端版本 Enterprise N LTSC 2019 客户端版本系统应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" equ "EnterpriseSN" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除系统应用菜单
	echo.===============================================================================
	echo.  [A]  指定访问锁定应用 ^| 依赖于：分配的访问权限
	echo.  [B]  Azure Active Directory AppX 代理插件
	echo.  [C]  生物注册应用
	echo.  [D]  Camera Barcode Scanner
	echo.  [E]  Content Delivery Manager ^| 需要全新体验应用程序
	echo.  [F]  Cortana、开始菜单和设置搜索应用 ^| 依赖于：语音识别
	echo.  [G]  Edge 开发者工具客户端
	echo.  [H]  目视控制应用
	echo.  [I]  文件资源管理器应用
	echo.  [J]  锁屏应用
	echo.  [K]  地图控件
	echo.  [L]  Narrator QuickStart
	echo.  [M]  家长控制应用
	echo.  [N]  人脉栏
	echo.  [O]  快速助手应用
	echo.  [P]  零售演示内容
	echo.  [Q]  设置同步
	echo.  [R]  Skype ORTC
	echo.  [S]  Smart Screen ^| 依赖于：Windows Defender
	echo.  [T]  Win32 Web View 主机
	echo.  [U]  Windows Defender 应用
	echo.  [V]  Windows 混合现实
	echo.  [W]  Windows 阅读器 ^(PDF^)
	echo.  [X]  Xbox Game Callable UI
	echo.
	echo.  [1]   所有系统应用
	echo.  [2]  返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWX12 /N /M "请输入你的选项 ："
	if errorlevel 26 goto :RemoveWindowsComponentsMenu
	if errorlevel 25 set "Component=SystemApps"
	if errorlevel 24 set "Component=XboxGameCallableUI"
	if errorlevel 23 set "Component=WindowsReaderPDF"
	if errorlevel 22 set "Component=WindowsMixedReality"
	if errorlevel 21 set "Component=WindowsDefender"
	if errorlevel 20 set "Component=Win32WebViewHost"
	if errorlevel 19 set "Component=SmartScreen"
	if errorlevel 18 set "Component=SkypeORTC"
	if errorlevel 17 set "Component=SettingSync"
	if errorlevel 16 set "Component=RetailDemoContent"
	if errorlevel 15 set "Component=QuickAssist"
	if errorlevel 14 set "Component=PeopleExperienceHost"
	if errorlevel 13 set "Component=ParentalControls"
	if errorlevel 12 set "Component=NarratorQuickStart"
	if errorlevel 11 set "Component=MapControl"
	if errorlevel 10 set "Component=LockApp"
	if errorlevel 9  set "Component=FileExplorer"
	if errorlevel 8  set "Component=ECApp"
	if errorlevel 7  set "Component=EdgeDevToolsClient"
	if errorlevel 6  set "Component=Cortana"
	if errorlevel 5  set "Component=ContentDeliveryManager"
	if errorlevel 4  set "Component=CBSPreview"
	if errorlevel 3  set "Component=BioEnrollment"
	if errorlevel 2  set "Component=AADBrokerPlugin"
	if errorlevel 1  set "Component=AssignedAccessLockApp"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v1809 客户端版本系统应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除系统应用菜单
	echo.===============================================================================
	echo.  [A]  指定访问锁定应用 ^| 依赖于：分配的访问权限
	echo.  [B]  Azure Active Directory AppX 代理插件
	echo.  [C]  生物注册应用
	echo.  [D]  Camera Barcode Scanner
	echo.  [E]  连接应用
	echo.  [F]  Content Delivery Manager ^| 需要全新体验应用程序
	echo.  [G]  Cortana、开始菜单和设置搜索应用 ^| 依赖于：语音识别
	echo.  [H]  Edge
	echo.  [I]  目视控制应用
	echo.  [J]  文件资源管理器应用
	echo.  [K]  锁屏应用
	echo.  [L]  地图控件
	echo.  [M]  Narrator QuickStart
	echo.  [N]  OneDrive 桌面客户端
	echo.  [O]  家长控制应用
	echo.  [P]  人脉栏
	echo.  [Q]  快速助手应用
	echo.  [R]  零售演示内容
	echo.  [S]  设置同步
	echo.  [T]  Skype ORTC
	echo.  [U]  Smart Screen ^| 依赖于：Windows Defender
	echo.  [V]  Take Test 应用
	echo.  [W]  Win32 Web View 主机
	echo.  [X]  Windows Defender 应用
	echo.  [Y]  Windows 混合现实
	echo.  [Z]  Xbox Game Callable UI
	echo.
	echo.  [1]   所有系统应用
	echo.  [2]  返回
	echo.===============================================================================
	choice /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ12 /N /M "请输入你的选项 ："
	if errorlevel 28 goto :RemoveWindowsComponentsMenu
	if errorlevel 27 set "Component=SystemApps"
	if errorlevel 26 set "Component=XboxGameCallableUI"
	if errorlevel 25 set "Component=WindowsMixedReality"
	if errorlevel 24 set "Component=WindowsDefender"
	if errorlevel 23 set "Component=Win32WebViewHost"
	if errorlevel 22 set "Component=SecureAssessmentBrowser"
	if errorlevel 21 set "Component=SmartScreen"
	if errorlevel 20 set "Component=SkypeORTC"
	if errorlevel 19 set "Component=SettingSync"
	if errorlevel 18 set "Component=RetailDemoContent"
	if errorlevel 17 set "Component=QuickAssist"
	if errorlevel 16 set "Component=PeopleExperienceHost"
	if errorlevel 15 set "Component=ParentalControls"
	if errorlevel 14 set "Component=OneDrive"
	if errorlevel 13 set "Component=NarratorQuickStart"
	if errorlevel 12 set "Component=MapControl"
	if errorlevel 11 set "Component=LockApp"
	if errorlevel 10 set "Component=FileExplorer"
	if errorlevel 9  set "Component=ECApp"
	if errorlevel 8  set "Component=Edge"
	if errorlevel 7  set "Component=Cortana"
	if errorlevel 6  set "Component=ContentDeliveryManager"
	if errorlevel 5  set "Component=PPIProjection"
	if errorlevel 4  set "Component=CBSPreview"
	if errorlevel 3  set "Component=BioEnrollment"
	if errorlevel 2  set "Component=AADBrokerPlugin"
	if errorlevel 1  set "Component=AssignedAccessLockApp"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v1903/v1909 客户端版本系统应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "18362" if "%ImageBuild%" leq "18363" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除系统应用菜单
	echo.===============================================================================
	echo.  [01]  指定访问锁定应用 ^| 依赖于：分配的访问权限
	echo.  [02]  Azure Active Directory AppX 代理插件
	echo.  [03]  生物注册应用
	echo.  [04]  Calling Shell 应用
	echo.  [05]  Camera Barcode Scanner
	echo.  [06]  连接应用
	echo.  [07]  Content Delivery Manager ^| 需要全新体验应用程序
	echo.  [08]  Cortana、开始菜单和设置搜索应用 ^| 依赖于：语音识别
	echo.  [09]  Edge
	echo.  [10]  目视控制应用
	echo.  [11]  文件资源管理器应用
	echo.  [12]  锁屏应用
	echo.  [13]  地图控件
	echo.  [14]  Narrator QuickStart
	echo.  [15]  OneDrive 桌面客户端
	echo.  [16]  家长控制应用
	echo.  [17]  人脉栏
	echo.  [18]  快速助手应用
	echo.  [19]  零售演示内容
	echo.  [20]  设置同步
	echo.  [21]  Skype ORTC
	echo.  [22]  Smart Screen ^| 依赖于：Windows Defender
	echo.  [23]  Take Test 应用
	echo.  [24]  Win32 Web View 主机
	echo.  [25]  Windows Defender 应用
	echo.  [26]  Windows 混合现实
	echo.  [27]  Xbox Game Callable UI
	echo.
	echo.  [A]   所有系统应用
	echo.  [X]   返回
	echo.===============================================================================
	set /p MenuChoice=请输入你的选项 ： 

	if /i "!MenuChoice!" equ "X" goto :RemoveWindowsComponentsMenu
	if /i "!MenuChoice!" equ "A" set "Component=SystemApps"
	if "!MenuChoice!" equ "27" set "Component=XboxGameCallableUI"
	if "!MenuChoice!" equ "26" set "Component=WindowsMixedReality"
	if "!MenuChoice!" equ "25" set "Component=WindowsDefender"
	if "!MenuChoice!" equ "24" set "Component=Win32WebViewHost"
	if "!MenuChoice!" equ "23" set "Component=SecureAssessmentBrowser"
	if "!MenuChoice!" equ "22" set "Component=SmartScreen"
	if "!MenuChoice!" equ "21" set "Component=SkypeORTC"
	if "!MenuChoice!" equ "20" set "Component=SettingSync"
	if "!MenuChoice!" equ "19" set "Component=RetailDemoContent"
	if "!MenuChoice!" equ "18" set "Component=QuickAssist"
	if "!MenuChoice!" equ "17" set "Component=PeopleExperienceHost"
	if "!MenuChoice!" equ "16" set "Component=ParentalControls"
	if "!MenuChoice!" equ "15" set "Component=OneDrive"
	if "!MenuChoice!" equ "14" set "Component=NarratorQuickStart"
	if "!MenuChoice!" equ "13" set "Component=MapControl"
	if "!MenuChoice!" equ "12" set "Component=LockApp"
	if "!MenuChoice!" equ "11" set "Component=FileExplorer"
	if "!MenuChoice!" equ "10" set "Component=ECApp"
	if "!MenuChoice!" equ "09" set "Component=Edge"
	if "!MenuChoice!" equ "08" set "Component=Cortana"
	if "!MenuChoice!" equ "07" set "Component=ContentDeliveryManager"
	if "!MenuChoice!" equ "06" set "Component=PPIProjection"
	if "!MenuChoice!" equ "05" set "Component=CBSPreview"
	if "!MenuChoice!" equ "04" set "Component=CallingShellApp"
	if "!MenuChoice!" equ "03" set "Component=BioEnrollment"
	if "!MenuChoice!" equ "02" set "Component=AADBrokerPlugin"
	if "!MenuChoice!" equ "01" set "Component=AssignedAccessLockApp"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v2004/v2009 客户端版本系统应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除系统应用菜单
	echo.===============================================================================
	echo.  [01]  指定访问锁定应用 ^| 依赖于：分配的访问权限
	echo.  [02]  Azure Active Directory AppX 代理插件
	echo.  [03]  生物注册应用
	echo.  [04]  Calling Shell 应用
	echo.  [05]  Camera Barcode Scanner
	echo.  [06]  Content Delivery Manager ^| 需要全新体验应用程序
	echo.  [07]  Edge
	echo.  [08]  目视控制应用
	echo.  [09]  文件资源管理器应用
	echo.  [10]  锁屏应用
	echo.  [11]  地图控件
	echo.  [12]  Narrator QuickStart
	echo.  [13]  OneDrive 桌面客户端
	echo.  [14]  家长控制应用
	echo.  [15]  人脉栏
	echo.  [16]  快速助手应用
	echo.  [17]  零售演示内容
	echo.  [18]  设置同步
	echo.  [19]  Skype ORTC
	echo.  [20]  Smart Screen ^| 依赖于：Windows Defender
	echo.  [21]  Take Test 应用
	echo.  [22]  Win32 Web View 主机
	echo.  [23]  Windows Defender 应用
	echo.  [24]  Windows 混合现实
	echo.  [25]  Xbox Game Callable UI
	echo.
	echo.  [A]   所有系统应用
	echo.  [X]   返回
	echo.===============================================================================
	set /p MenuChoice=请输入你的选项 ： 

	if /i "!MenuChoice!" equ "X" goto :RemoveWindowsComponentsMenu
	if /i "!MenuChoice!" equ "A" set "Component=SystemApps"
	if "!MenuChoice!" equ "25" set "Component=XboxGameCallableUI"
	if "!MenuChoice!" equ "24" set "Component=WindowsMixedReality"
	if "!MenuChoice!" equ "23" set "Component=WindowsDefender"
	if "!MenuChoice!" equ "22" set "Component=Win32WebViewHost"
	if "!MenuChoice!" equ "21" set "Component=SecureAssessmentBrowser"
	if "!MenuChoice!" equ "20" set "Component=SmartScreen"
	if "!MenuChoice!" equ "19" set "Component=SkypeORTC"
	if "!MenuChoice!" equ "18" set "Component=SettingSync"
	if "!MenuChoice!" equ "17" set "Component=RetailDemoContent"
	if "!MenuChoice!" equ "16" set "Component=QuickAssist"
	if "!MenuChoice!" equ "15" set "Component=PeopleExperienceHost"
	if "!MenuChoice!" equ "14" set "Component=ParentalControls"
	if "!MenuChoice!" equ "13" set "Component=OneDrive"
	if "!MenuChoice!" equ "12" set "Component=NarratorQuickStart"
	if "!MenuChoice!" equ "11" set "Component=MapControl"
	if "!MenuChoice!" equ "10" set "Component=LockApp"
	if "!MenuChoice!" equ "09" set "Component=FileExplorer"
	if "!MenuChoice!" equ "08" set "Component=ECApp"
	if "!MenuChoice!" equ "07" set "Component=Edge"
	if "!MenuChoice!" equ "06" set "Component=ContentDeliveryManager"
	if "!MenuChoice!" equ "05" set "Component=CBSPreview"
	if "!MenuChoice!" equ "04" set "Component=CallingShellApp"
	if "!MenuChoice!" equ "03" set "Component=BioEnrollment"
	if "!MenuChoice!" equ "02" set "Component=AADBrokerPlugin"
	if "!MenuChoice!" equ "01" set "Component=AssignedAccessLockApp"

	goto :RemoveWindowsComponents
)

:RemoveWindowsAppsMenu
:: 移除 Windows 10 v1809 客户端版本 Enterprise LTSC 2019 客户端版本系统应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" equ "EnterpriseS" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除系统应用菜单
	echo.===============================================================================
	echo.
	echo.  [1]  Windows 应用商店后端 ^| 依赖于：Smart Screen
	echo.
	echo.  [2]  Xbox 应用后端
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :RemoveWindowsComponentsMenu
	if errorlevel 2 set "Component=XboxApp"
	if errorlevel 1 set "Component=WindowsStore"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v1809 客户端版本 Enterprise N LTSC 2019 客户端版本系统应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageFlag%" equ "EnterpriseSN" (
	cls
	echo.===============================================================================
	echo.                       MSMG 工具箱 - 移除系统应用菜单
	echo.===============================================================================
	echo.
	echo.  [1]  Windows 应用商店后端 ^| 依赖于：Smart Screen
	echo.
	echo.  [2]  Xbox 应用后端
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]  返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:12X /N /M "请输入你的选项 ："
	if errorlevel 3 goto :RemoveWindowsComponentsMenu
	if errorlevel 2 set "Component=XboxApp"
	if errorlevel 1 set "Component=WindowsStore"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v1809/v1903/v1909 客户端版本 32-位客户端版本 Windows 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "18363" if "%ImageArchitecture%" equ "x86" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	cls
	echo.===============================================================================
	echo.                     MSMG 工具箱 - 移除 Windows 应用菜单
	echo.===============================================================================
	echo.  [01]  Advertising Xaml
	echo.  [02]  闹钟和时钟应用
	echo.  [03]  计算器应用
	echo.  [04]  相机应用
	echo.  [05]  桌面应用安装程序
	echo.  [06]  反馈中心应用
	echo.  [07]  电影和电视应用
	echo.  [08]  获取帮助应用
	echo.  [09]  Google 的 VP9 WebM 视频编解码器插件
	echo.  [10]  Groove 音乐应用
	echo.  [11]  高效图像文件 ^(HEIF^) 编解码器插件
	echo.  [12]  地图应用 ^| 依赖于：地图控件
	echo.  [13]  消息应用
	echo.  [14]  Microsoft Pay 应用
	echo.  [15]  混合现实查看器应用 ^| 依赖于：Windows 混合现实
	echo.  [16]  移动套餐应用
	echo.  [17]  我的 Office 应用
	echo.  [18]  OneNote 应用
	echo.  [19]  画图 3D 应用
	echo.  [20]  人脉应用 ^| 依赖于：人脉栏
	echo.  [21]  照片应用
	echo.  [22]  Print 3D 应用
	echo.  [23]  屏幕和草图应用
	echo.  [24]  Skype 应用
	echo.  [25]  Solitaire Collection 应用 ^| 依赖于：Xbox Game Callable UI
	if "%ImageBuild%" equ "17763" echo.  [26]  便笺应用
	if "%ImageBuild%" neq "17763" echo.  [26]  便笺应用 ^| 依赖于：Windows 应用商店
	echo.  [27]  使用技巧应用
	echo.  [28]  录音机应用
	echo.  [29]  天气应用 ^| 依赖于：Advertising Xaml
	echo.  [30]  Web 媒体编解码器插件
	echo.  [31]  WebP 图像编解码器插件
	echo.  [32]  Windows 邮件应用 ^| 依赖于：Advertising Xaml
	echo.  [33]  Windows 应用商店 ^| 依赖于：Smart Screen
	echo.  [34]  Xbox 应用
	echo.  [35]  Xbox Identity Provider
	echo.  [36]  你的手机应用
	echo.
	echo.  [A]   所有 Windows 应用
	echo.  [X]   返回
	echo.===============================================================================
	set /p MenuChoice=请输入你的选项 ： 

	if /i "!MenuChoice!" equ "X" goto :RemoveWindowsComponentsMenu
	if /i "!MenuChoice!" equ "A" set "Component=WindowsApps"
	if "!MenuChoice!" equ "36" set "Component=YourPhone"
	if "!MenuChoice!" equ "35" set "Component=XboxIdentityProvider"
	if "!MenuChoice!" equ "34" set "Component=XboxApp"
	if "!MenuChoice!" equ "33" set "Component=WindowsStore"
	if "!MenuChoice!" equ "32" set "Component=CommunicationsApps"
	if "!MenuChoice!" equ "31" set "Component=WebpImageExtensions"
	if "!MenuChoice!" equ "30" set "Component=WebMediaExtensions"
	if "!MenuChoice!" equ "29" set "Component=BingWeather"
	if "!MenuChoice!" equ "28" set "Component=SoundRecorder"
	if "!MenuChoice!" equ "27" set "Component=Getstarted"
	if "!MenuChoice!" equ "26" set "Component=StickyNotes"
	if "!MenuChoice!" equ "25" set "Component=SolitaireCollection"
	if "!MenuChoice!" equ "24" set "Component=SkypeApp"
	if "!MenuChoice!" equ "23" set "Component=ScreenSketch"
	if "!MenuChoice!" equ "22" set "Component=Print3D"
	if "!MenuChoice!" equ "21" set "Component=Photos"
	if "!MenuChoice!" equ "20" set "Component=People"
	if "!MenuChoice!" equ "19" set "Component=Paint3D"
	if "!MenuChoice!" equ "18" set "Component=OfficeOneNote"
	if "!MenuChoice!" equ "17" set "Component=OfficeHub"
	if "!MenuChoice!" equ "16" set "Component=OneConnect"
	if "!MenuChoice!" equ "15" set "Component=3DViewer"
	if "!MenuChoice!" equ "14" set "Component=WalletService"
	if "!MenuChoice!" equ "13" set "Component=Messaging"
	if "!MenuChoice!" equ "12" set "Component=Maps"
	if "!MenuChoice!" equ "11" set "Component=HEIFImageExtension"
	if "!MenuChoice!" equ "10" set "Component=ZuneMusic"
	if "!MenuChoice!" equ "09" set "Component=VP9VideoExtensions"
	if "!MenuChoice!" equ "08" set "Component=GetHelp"
	if "!MenuChoice!" equ "07" set "Component=ZuneVideo"
	if "!MenuChoice!" equ "06" set "Component=FeedbackHub"
	if "!MenuChoice!" equ "05" set "Component=DesktopAppInstaller"
	if "!MenuChoice!" equ "04" set "Component=Camera"
	if "!MenuChoice!" equ "03" set "Component=Calculator"	
	if "!MenuChoice!" equ "02" set "Component=Alarms"
	if "!MenuChoice!" equ "01" set "Component=AdvertisingXaml"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v1809/v1903/v1909 客户端非企业版 (N) LTSC 2019 64-位客户端版本 Windows 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "18363" if "%ImageArchitecture%" equ "x64" if "%ImageFlag%" neq "EnterpriseS" if "%ImageFlag%" neq "EnterpriseSN" (
	cls
	echo.===============================================================================
	echo.                     MSMG 工具箱 - 移除 Windows 应用菜单
	echo.===============================================================================
	echo.  [01]  Advertising Xaml
	echo.  [02]  闹钟和时钟应用
	echo.  [03]  计算器应用
	echo.  [04]  相机应用
	echo.  [05]  桌面应用安装程序
	echo.  [06]  反馈中心应用
	echo.  [07]  电影和电视应用
	echo.  [08]  获取帮助应用
	echo.  [09]  Google 的 VP9 WebM 视频编解码器插件
	echo.  [10]  Groove 音乐应用
	echo.  [11]  高效图像文件 ^(HEIF^) 编解码器插件
	echo.  [12]  地图应用 ^| 依赖于：地图控件
	echo.  [13]  消息应用
	echo.  [14]  Microsoft Pay 应用
	echo.  [15]  混合现实门户应用 ^| 依赖于：Windows 混合现实
	echo.  [16]  混合现实查看器应用 ^| 依赖于：Windows 混合现实
	echo.  [17]  移动套餐应用
	echo.  [18]  我的 Office 应用
	echo.  [19]  OneNote 应用
	echo.  [20]  画图 3D 应用
	echo.  [21]  人脉应用 ^| 依赖于：人脉栏
	echo.  [22]  照片应用
	echo.  [23]  Print 3D 应用
	echo.  [24]  屏幕和草图应用
	echo.  [25]  Skype 应用
	echo.  [26]  Solitaire Collection 应用 ^| 依赖于：Xbox Game Callable UI
	if "%ImageBuild%" equ "17763" echo.  [27]  便笺应用
	if "%ImageBuild%" neq "17763" echo.  [27]  便笺应用 ^| 依赖于：Windows 应用商店
	echo.  [28]  使用技巧应用
	echo.  [29]  录音机应用
	echo.  [30]  天气应用 ^| 依赖于：Advertising Xaml
	echo.  [31]  Web 媒体编解码器插件
	echo.  [32]  WebP 图像编解码器插件
	echo.  [33]  Windows 邮件应用 ^| 依赖于：Advertising Xaml
	echo.  [34]  Windows 应用商店 ^| 依赖于：Smart Screen
	echo.  [35]  Xbox 应用
	echo.  [36]  Xbox Identity Provider
	echo.  [37]  你的手机应用
	echo.
	echo.  [A]   所有 Windows 应用
	echo.  [X]   返回
	echo.===============================================================================
	set /p MenuChoice=请输入你的选项 ： 

	if /i "!MenuChoice!" equ "X" goto :RemoveWindowsComponentsMenu
	if /i "!MenuChoice!" equ "A" set "Component=WindowsApps"
	if "!MenuChoice!" equ "37" set "Component=YourPhone"
	if "!MenuChoice!" equ "36" set "Component=XboxIdentityProvider"
	if "!MenuChoice!" equ "35" set "Component=XboxApp"
	if "!MenuChoice!" equ "34" set "Component=WindowsStore"
	if "!MenuChoice!" equ "33" set "Component=CommunicationsApps"
	if "!MenuChoice!" equ "32" set "Component=WebpImageExtensions"
	if "!MenuChoice!" equ "31" set "Component=WebMediaExtensions"
	if "!MenuChoice!" equ "30" set "Component=BingWeather"
	if "!MenuChoice!" equ "29" set "Component=SoundRecorder"
	if "!MenuChoice!" equ "28" set "Component=Getstarted"
	if "!MenuChoice!" equ "27" set "Component=StickyNotes"
	if "!MenuChoice!" equ "26" set "Component=SolitaireCollection"
	if "!MenuChoice!" equ "25" set "Component=SkypeApp"
	if "!MenuChoice!" equ "24" set "Component=ScreenSketch"
	if "!MenuChoice!" equ "23" set "Component=Print3D"
	if "!MenuChoice!" equ "22" set "Component=Photos"
	if "!MenuChoice!" equ "21" set "Component=People"
	if "!MenuChoice!" equ "20" set "Component=Paint3D"
	if "!MenuChoice!" equ "19" set "Component=OfficeOneNote"
	if "!MenuChoice!" equ "18" set "Component=OfficeHub"
	if "!MenuChoice!" equ "17" set "Component=OneConnect"
	if "!MenuChoice!" equ "16" set "Component=3DViewer"
	if "!MenuChoice!" equ "15" set "Component=MixedRealityPortal"
	if "!MenuChoice!" equ "14" set "Component=WalletService"
	if "!MenuChoice!" equ "13" set "Component=Messaging"
	if "!MenuChoice!" equ "12" set "Component=Maps"
	if "!MenuChoice!" equ "11" set "Component=HEIFImageExtension"
	if "!MenuChoice!" equ "10" set "Component=ZuneMusic"
	if "!MenuChoice!" equ "09" set "Component=VP9VideoExtensions"
	if "!MenuChoice!" equ "08" set "Component=GetHelp"
	if "!MenuChoice!" equ "07" set "Component=ZuneVideo"
	if "!MenuChoice!" equ "06" set "Component=FeedbackHub"
	if "!MenuChoice!" equ "05" set "Component=DesktopAppInstaller"
	if "!MenuChoice!" equ "04" set "Component=Camera"
	if "!MenuChoice!" equ "03" set "Component=Calculator"	
	if "!MenuChoice!" equ "02" set "Component=Alarms"
	if "!MenuChoice!" equ "01" set "Component=AdvertisingXaml"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v2004/v2009 32-位客户端版本 Windows 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" if "%ImageArchitecture%" equ "x86" (
	cls
	echo.===============================================================================
	echo.                     MSMG 工具箱 - 移除 Windows 应用菜单
	echo.===============================================================================
	echo.  [01]  Advertising Xaml
	echo.  [02]  闹钟和时钟应用
	echo.  [03]  计算器应用
	echo.  [04]  相机应用
	echo.  [05]  Cortana 应用
	echo.  [06]  桌面应用安装程序
	echo.  [07]  反馈中心应用
	echo.  [08]  获取帮助应用
	echo.  [09]  Google 的 VP9 WebM 视频编解码器插件
	echo.  [10]  Groove 音乐应用
	echo.  [11]  高效图像文件 ^(HEIF^) 编解码器插件
	echo.  [12]  地图应用 ^| 依赖于：地图控件
	echo.  [13]  Microsoft Pay 应用
	echo.  [14]  混合现实查看器应用 ^| 依赖于：Windows 混合现实
	echo.  [15]  电影和电视应用
	echo.  [16]  我的 Office 应用
	echo.  [17]  OneNote 应用
	echo.  [18]  画图 3D 应用
	echo.  [19]  人脉应用 ^| 依赖于：人脉栏
	echo.  [20]  照片应用
	echo.  [21]  屏幕和草图应用
	echo.  [22]  Skype 应用
	echo.  [23]  Solitaire Collection 应用 ^| 依赖于：Xbox Game Callable UI
	echo.  [24]  便笺应用 ^| 依赖于：Windows 应用商店
	echo.  [25]  使用技巧应用
	echo.  [26]  录音机应用
	echo.  [27]  天气应用 ^| 依赖于：Advertising Xaml
	echo.  [28]  Web 媒体编解码器插件
	echo.  [29]  WebP 图像编解码器插件
	echo.  [30]  Windows 邮件应用 ^| 依赖于：Advertising Xaml
	echo.  [31]  Windows 应用商店 ^| 依赖于：Smart Screen
	echo.  [32]  Xbox 应用
	echo.  [33]  Xbox Identity Provider
	echo.  [34]  你的手机应用
	echo.
	echo.  [A]   所有 Windows 应用
	echo.  [X]   返回
	echo.===============================================================================
	set /p MenuChoice=请输入你的选项 ： 

	if /i "!MenuChoice!" equ "X" goto :RemoveWindowsComponentsMenu
	if /i "!MenuChoice!" equ "A" set "Component=WindowsApps"
	if "!MenuChoice!" equ "34" set "Component=YourPhone"
	if "!MenuChoice!" equ "33" set "Component=XboxIdentityProvider"
	if "!MenuChoice!" equ "32" set "Component=XboxApp"
	if "!MenuChoice!" equ "31" set "Component=WindowsStore"
	if "!MenuChoice!" equ "30" set "Component=CommunicationsApps"
	if "!MenuChoice!" equ "29" set "Component=WebpImageExtensions"
	if "!MenuChoice!" equ "28" set "Component=WebMediaExtensions"
	if "!MenuChoice!" equ "27" set "Component=BingWeather"
	if "!MenuChoice!" equ "26" set "Component=SoundRecorder"
	if "!MenuChoice!" equ "25" set "Component=Getstarted"
	if "!MenuChoice!" equ "24" set "Component=StickyNotes"
	if "!MenuChoice!" equ "23" set "Component=SolitaireCollection"
	if "!MenuChoice!" equ "22" set "Component=SkypeApp"
	if "!MenuChoice!" equ "21" set "Component=ScreenSketch"
	if "!MenuChoice!" equ "20" set "Component=Photos"
	if "!MenuChoice!" equ "19" set "Component=People"
	if "!MenuChoice!" equ "18" set "Component=Paint3D"
	if "!MenuChoice!" equ "17" set "Component=OfficeOneNote"
	if "!MenuChoice!" equ "16" set "Component=OfficeHub"
	if "!MenuChoice!" equ "15" set "Component=ZuneVideo"
	if "!MenuChoice!" equ "14" set "Component=3DViewer"
	if "!MenuChoice!" equ "13" set "Component=WalletService"
	if "!MenuChoice!" equ "12" set "Component=Maps"
	if "!MenuChoice!" equ "11" set "Component=HEIFImageExtension"
	if "!MenuChoice!" equ "10" set "Component=ZuneMusic"
	if "!MenuChoice!" equ "09" set "Component=VP9VideoExtensions"
	if "!MenuChoice!" equ "08" set "Component=GetHelp"
	if "!MenuChoice!" equ "07" set "Component=FeedbackHub"
	if "!MenuChoice!" equ "06" set "Component=DesktopAppInstaller"
	if "!MenuChoice!" equ "05" set "Component=Cortana"
	if "!MenuChoice!" equ "04" set "Component=Camera"
	if "!MenuChoice!" equ "03" set "Component=Calculator"	
	if "!MenuChoice!" equ "02" set "Component=Alarms"
	if "!MenuChoice!" equ "01" set "Component=AdvertisingXaml"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 10 v2004/v2009 64-位客户端版本 Windows 应用菜单
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" if "%ImageArchitecture%" equ "x64" (
	cls
	echo.===============================================================================
	echo.                     MSMG 工具箱 - 移除 Windows 应用菜单
	echo.===============================================================================
	echo.  [01]  Advertising Xaml
	echo.  [02]  闹钟和时钟应用
	echo.  [03]  计算器应用
	echo.  [04]  相机应用
	echo.  [05]  Cortana 应用
	echo.  [06]  桌面应用安装程序
	echo.  [07]  反馈中心应用
	echo.  [08]  获取帮助应用
	echo.  [09]  Google 的 VP9 WebM 视频编解码器插件
	echo.  [10]  Groove 音乐应用
	echo.  [11]  高效图像文件 ^(HEIF^) 编解码器插件
	echo.  [12]  地图应用 ^| 依赖于：地图控件
	echo.  [13]  Microsoft Pay 应用
	echo.  [14]  混合现实门户应用 ^| 依赖于：Windows 混合现实
	echo.  [15]  混合现实查看器应用 ^| 依赖于：Windows 混合现实
	echo.  [16]  电影和电视应用
	echo.  [17]  我的 Office 应用
	echo.  [18]  OneNote 应用
	echo.  [19]  画图 3D 应用
	echo.  [20]  人脉应用 ^| 依赖于：人脉栏
	echo.  [21]  照片应用
	echo.  [22]  屏幕和草图应用
	echo.  [23]  Skype 应用
	echo.  [24]  Solitaire Collection 应用 ^| 依赖于：Xbox Game Callable UI
	echo.  [25]  便笺应用 ^| 依赖于：Windows 应用商店
	echo.  [26]  使用技巧应用
	echo.  [27]  录音机应用
	echo.  [28]  天气应用 ^| 依赖于：Advertising Xaml
	echo.  [29]  Web 媒体编解码器插件
	echo.  [30]  WebP 图像编解码器插件
	echo.  [31]  Windows 邮件应用 ^| 依赖于：Advertising Xaml
	echo.  [32]  Windows 应用商店 ^| 依赖于：Smart Screen
	echo.  [33]  Xbox 应用
	echo.  [34]  Xbox Identity Provider
	echo.  [35]  你的手机应用
	echo.
	echo.  [A]   所有 Windows 应用
	echo.  [X]   返回
	echo.===============================================================================
	set /p MenuChoice=请输入你的选项 ： 

	if /i "!MenuChoice!" equ "X" goto :RemoveWindowsComponentsMenu
	if /i "!MenuChoice!" equ "A" set "Component=WindowsApps"
	if "!MenuChoice!" equ "35" set "Component=YourPhone"
	if "!MenuChoice!" equ "34" set "Component=XboxIdentityProvider"
	if "!MenuChoice!" equ "33" set "Component=XboxApp"
	if "!MenuChoice!" equ "32" set "Component=WindowsStore"
	if "!MenuChoice!" equ "31" set "Component=CommunicationsApps"
	if "!MenuChoice!" equ "30" set "Component=WebpImageExtensions"
	if "!MenuChoice!" equ "29" set "Component=WebMediaExtensions"
	if "!MenuChoice!" equ "28" set "Component=BingWeather"
	if "!MenuChoice!" equ "27" set "Component=SoundRecorder"
	if "!MenuChoice!" equ "26" set "Component=Getstarted"
	if "!MenuChoice!" equ "25" set "Component=StickyNotes"
	if "!MenuChoice!" equ "24" set "Component=SolitaireCollection"
	if "!MenuChoice!" equ "23" set "Component=SkypeApp"
	if "!MenuChoice!" equ "22" set "Component=ScreenSketch"
	if "!MenuChoice!" equ "21" set "Component=Photos"
	if "!MenuChoice!" equ "20" set "Component=People"
	if "!MenuChoice!" equ "19" set "Component=Paint3D"
	if "!MenuChoice!" equ "18" set "Component=OfficeOneNote"
	if "!MenuChoice!" equ "17" set "Component=OfficeHub"
	if "!MenuChoice!" equ "16" set "Component=ZuneVideo"
	if "!MenuChoice!" equ "15" set "Component=3DViewer"
	if "!MenuChoice!" equ "14" set "Component=MixedRealityPortal"
	if "!MenuChoice!" equ "13" set "Component=WalletService"
	if "!MenuChoice!" equ "12" set "Component=Maps"
	if "!MenuChoice!" equ "11" set "Component=HEIFImageExtension"
	if "!MenuChoice!" equ "10" set "Component=ZuneMusic"
	if "!MenuChoice!" equ "09" set "Component=VP9VideoExtensions"
	if "!MenuChoice!" equ "08" set "Component=GetHelp"
	if "!MenuChoice!" equ "07" set "Component=FeedbackHub"
	if "!MenuChoice!" equ "06" set "Component=DesktopAppInstaller"
	if "!MenuChoice!" equ "05" set "Component=Cortana"
	if "!MenuChoice!" equ "04" set "Component=Camera"
	if "!MenuChoice!" equ "03" set "Component=Calculator"	
	if "!MenuChoice!" equ "02" set "Component=Alarms"
	if "!MenuChoice!" equ "01" set "Component=AdvertisingXaml"

	goto :RemoveWindowsComponents
)

:: 移除 Windows 组件
:RemoveWindowsComponents

cls
echo.===============================================================================
echo.                       MSMG 工具箱 - 移除 Windows 组件
echo.===============================================================================
echo.

if "%Component%" equ "InternetComponents" (
	choice /C YN /N /M "继续移除所有 Internet 组件…… [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

if "%Component%" equ "MultimediaComponents" (
	choice /C YN /N /M "继续移除所有多媒体组件…… [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

if "%Component%" equ "PrivacyComponents" (
	choice /C YN /N /M "继续移除所有隐私组件…… [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

if "%Component%" equ "RemotingComponents" (
	choice /C YN /N /M "继续移除所有远程处理组件组件…… [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

if "%Component%" equ "SystemComponents" (
	choice /C YN /N /M "继续移除所有系统组件…… [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

if "%Component%" equ "SystemApps" (
	choice /C YN /N /M "继续移除所有系统应用…… [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

if "%Component%" equ "WindowsApps" (
	choice /C YN /N /M "继续移除所有 Windows 应用…… [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :Stop
)

cls
echo.===============================================================================
echo.                       MSMG 工具箱 - 移除 Windows 组件
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

:: 设置软件包体系结构
if "%ImageArchitecture%" equ "x86" set "PackageArchitecture=x86"
if "%ImageArchitecture%" equ "x64" set "PackageArchitecture=amd64"
if "%ImageArchitecture%" equ "arm64" set "PackageArchitecture=arm64"

echo.-------------------------------------------------------------------------------
echo.####正在开始移除 Windows 组件##################################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在移除 Windows 组件######################################################
echo.-------------------------------------------------------------------------------
echo.

if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not "%ImageIndexNo%" gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if "%ImageIndexNo%" gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.

		:: 获取安装映像索引体系结构
		call :GetImageIndexInfo "%InstallWim%", %%i >nul

		:: Internet 组件
		if "%Component%" equ "AdobeFlashForWindows" call :RemoveWindowsComponent "%InstallMount%\%%i", "适用于 Windows 的 Adobe Flash", "AdobeFlashForWindows"
		if "%Component%" equ "EdgeChromium" call :RemoveWindowsComponent "%InstallMount%\%%i", "Edge Chromium 浏览器", "EdgeChromium"
		if "%Component%" equ "InternetExplorer" call :RemoveWindowsComponent "%InstallMount%\%%i", "Internet Explorer", "InternetExplorer"

		:: 多媒体组件
		if "%Component%" equ "FirstLogonAnimation" call :RemoveWindowsComponent "%InstallMount%\%%i", "首次登录动画", "FirstLogonAnimation"
		if "%Component%" equ "GameExplorer" call :RemoveWindowsComponent "%InstallMount%\%%i", "游戏浏览器", "GameExplorer"
		if "%Component%" equ "SnippingTool" call :RemoveWindowsComponent "%InstallMount%\%%i", "截图工具", "SnippingTool"
		if "%Component%" equ "SpeechRecognition" call :RemoveWindowsComponent "%InstallMount%\%%i", "语音识别", "SpeechRecognition"
		if "%Component%" equ "WindowsMediaPlayer" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows Media Player", "WindowsMediaPlayer"
		if "%Component%" equ "WindowsPhotoViewer" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 照片查看器", "WindowsPhotoViewer"
		if "%Component%" equ "WinSAT" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 系统评估工具", "WinSAT"

		:: 隐私组件
		if "%Component%" equ "AssignedAccess" call :RemoveWindowsComponent "%InstallMount%\%%i", "分配的访问权限", "AssignedAccess"
		if "%Component%" equ "CEIP_SQM" call :RemoveWindowsComponent "%InstallMount%\%%i", "客户体验改善计划 [CEIP]", "CEIP_SQM"
		if "%Component%" equ "FaceRecognition" call :RemoveWindowsComponent "%InstallMount%\%%i", "人脸识别", "FaceRecognition"
		if "%Component%" equ "KernelDebugging" call :RemoveWindowsComponent "%InstallMount%\%%i", "内核调试", "KernelDebugging"
		if "%Component%" equ "LocationService" call :RemoveWindowsComponent "%InstallMount%\%%i", "定位服务", "LocationService"
		if "%Component%" equ "PicturePassword" call :RemoveWindowsComponent "%InstallMount%\%%i", "图片密码", "PicturePassword"
		if "%Component%" equ "PinEnrollment" call :RemoveWindowsComponent "%InstallMount%\%%i", "Pin Enrollment", "PinEnrollment"
		if "%Component%" equ "UnifiedTelemetryClient" call :RemoveWindowsComponent "%InstallMount%\%%i", "统一遥测客户端 [Asimov]", "UnifiedTelemetryClient"
		if "%Component%" equ "WiFiNetworkManager" call :RemoveWindowsComponent "%InstallMount%\%%i", "WiFi Network Manager", "WiFiNetworkManager"
		if "%Component%" equ "WindowsErrorReporting" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 错误报告", "WindowsErrorReporting"
		if "%Component%" equ "WindowsInsiderHub" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 会员中心", "WindowsInsiderHub"

		:: 远程处理组件
		if "%Component%" equ "HomeGroup" call :RemoveWindowsComponent "%InstallMount%\%%i", "家庭组", "HomeGroup"
		if "%Component%" equ "MultiPointConnector" call :RemoveWindowsComponent "%InstallMount%\%%i", "MultiPoint Connector", "MultiPointConnector"
		if "%Component%" equ "RemoteAssistance" call :RemoveWindowsComponent "%InstallMount%\%%i", "远程协助", "RemoteAssistance"

		:: 系统组件
		if "%Component%" equ "DeviceLockdown" call :RemoveWindowsComponent "%InstallMount%\%%i", "设备锁定 [嵌入式体验]", "DeviceLockdown"
		if "%Component%" equ "EaseOfAccessThemes" call :RemoveWindowsComponent "%InstallMount%\%%i", "轻松访问主题", "EaseOfAccessThemes"
		if "%Component%" equ "EasyTransfer" call :RemoveWindowsComponent "%InstallMount%\%%i", "轻松传送", "EasyTransfer"
		if "%Component%" equ "FileHistory" call :RemoveWindowsComponent "%InstallMount%\%%i", "文件历史记录", "FileHistory"
		if "%Component%" equ "ManualSetup" call :RemoveWindowsManualSetup
		if "%Component%" equ "Paint" call :RemoveWindowsComponent "%InstallMount%\%%i", "Microsoft 画图", "Paint"
		if "%Component%" equ "SecurityCenter" call :RemoveWindowsComponent "%InstallMount%\%%i", "安全中心", "SecurityCenter"
		if "%Component%" equ "StepsRecorder" call :RemoveWindowsComponent "%InstallMount%\%%i", "步骤记录器", "StepsRecorder"
		if "%Component%" equ "SystemRestore" call :RemoveWindowsComponent "%InstallMount%\%%i", "系统恢复", "SystemRestore"
		if "%Component%" equ "WindowsBackup" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 备份", "WindowsBackup"
		if "%Component%" equ "WindowsSubsystemForLinux" call :RemoveWindowsComponent "%InstallMount%\%%i", "适用于 Linux 的 Windows 子系统", "WindowsSubsystemForLinux"
		if "%Component%" equ "WindowsToGo" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows To Go", "WindowsToGo"
		if "%Component%" equ "Wordpad" call :RemoveWindowsComponent "%InstallMount%\%%i", "写字板", "Wordpad"

		:: 系统应用
		if "%Component%" equ "AADBrokerPlugin" call :RemoveWindowsComponent "%InstallMount%\%%i", "Azure Active Directory AppX 代理插件", "AADBrokerPlugin"
		if "%Component%" equ "AssignedAccessLockApp" call :RemoveWindowsComponent "%InstallMount%\%%i", "指定访问锁定应用", "AssignedAccessLockApp"
		if "%Component%" equ "BioEnrollment" call :RemoveWindowsComponent "%InstallMount%\%%i", "生物注册应用", "BioEnrollment"
		if "%Component%" equ "CallingShellApp" call :RemoveWindowsComponent "%InstallMount%\%%i", "Calling Shell 应用", "CallingShellApp"
		if "%Component%" equ "CBSPreview" call :RemoveWindowsComponent "%InstallMount%\%%i", "Camera Barcode Scanner", "CBSPreview"
		if "%Component%" equ "ContentDeliveryManager" call :RemoveWindowsComponent "%InstallMount%\%%i", "Content Delivery Manager", "ContentDeliveryManager"
		if "%Component%" equ "Cortana" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "18363" call :RemoveWindowsComponent "%InstallMount%\%%i", "Cortana、开始菜单和设置搜索应用", "Cortana"
		if "%Component%" equ "ECApp" call :RemoveWindowsComponent "%InstallMount%\%%i", "目视控制应用", "ECApp"

		if "%Component%" equ "Edge" (
			call :RemoveWindowsComponent "%InstallMount%\%%i", "Edge 开发者工具客户端", "EdgeDevToolsClient"
			call :RemoveWindowsComponent "%InstallMount%\%%i", "Edge 浏览器应用", "Edge"
			call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 阅读器 [PDF]", "WindowsReaderPDF"
		)

		if "%Component%" equ "EdgeDevToolsClient" call :RemoveWindowsComponent "%InstallMount%\%%i", "Edge 开发者工具客户端", "EdgeDevToolsClient"
		if "%Component%" equ "FileExplorer" call :RemoveWindowsComponent "%InstallMount%\%%i", "文件资源管理器应用", "FileExplorer"
		if "%Component%" equ "LockApp" call :RemoveWindowsComponent "%InstallMount%\%%i", "锁屏应用", "LockApp"
		if "%Component%" equ "MapControl" call :RemoveWindowsComponent "%InstallMount%\%%i", "地图控件", "MapControl"
		if "%Component%" equ "NarratorQuickStart" call :RemoveWindowsComponent "%InstallMount%\%%i", "Narrator QuickStart", "NarratorQuickStart"
		if "%Component%" equ "OneDrive" call :RemoveWindowsComponent "%InstallMount%\%%i", "OneDrive 桌面客户端", "OneDrive"
		if "%Component%" equ "ParentalControls" call :RemoveWindowsComponent "%InstallMount%\%%i", "家长控制应用", "ParentalControls"
		if "%Component%" equ "PeopleExperienceHost" call :RemoveWindowsComponent "%InstallMount%\%%i", "People Experience 主机", "PeopleExperienceHost"
		if "%Component%" equ "PPIProjection" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "18363" call :RemoveWindowsComponent "%InstallMount%\%%i", "连接应用", "PPIProjection"
		if "%Component%" equ "QuickAssist" call :RemoveWindowsComponent "%InstallMount%\%%i", "快速助手应用", "QuickAssist"
		if "%Component%" equ "RetailDemoContent" call :RemoveWindowsComponent "%InstallMount%\%%i", "零售演示内容", "RetailDemoContent"
		if "%Component%" equ "SecureAssessmentBrowser" call :RemoveWindowsComponent "%InstallMount%\%%i", "Take Test 应用", "SecureAssessmentBrowser"
		if "%Component%" equ "SettingSync" call :RemoveWindowsComponent "%InstallMount%\%%i", "设置同步", "SettingSync"
		if "%Component%" equ "SkypeORTC" call :RemoveWindowsComponent "%InstallMount%\%%i", "Skype ORTC", "SkypeORTC"
		if "%Component%" equ "SmartScreen" call :RemoveWindowsComponent "%InstallMount%\%%i", "SmartScreen 应用", "SmartScreen"
		if "%Component%" equ "Win32WebViewHost" call :RemoveWindowsComponent "%InstallMount%\%%i", "Win32 WebView 主机", "Win32WebViewHost"
		if "%Component%" equ "WindowsDefender" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows Defender 应用", "WindowsDefender"
		if "%Component%" equ "WindowsMixedReality" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 混合现实", "WindowsMixedReality"
		if "%Component%" equ "WindowsReaderPDF" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 阅读器 [PDF]", "WindowsReaderPDF"
		if "%Component%" equ "XboxGameCallableUI" call :RemoveWindowsComponent "%InstallMount%\%%i", "Xbox Game Callable UI", "XboxGameCallableUI"

		:: Windows 应用
		if "%Component%" equ "3DViewer" call :RemoveWindowsComponent "%InstallMount%\%%i", "混合现实查看器应用", "3DViewer"
		if "%Component%" equ "AdvertisingXaml" call :RemoveWindowsComponent "%InstallMount%\%%i", "Advertising Xaml", "AdvertisingXaml"
		if "%Component%" equ "Alarms" call :RemoveWindowsComponent "%InstallMount%\%%i", "闹钟和时钟应用", "Alarms"
		if "%Component%" equ "BingWeather" call :RemoveWindowsComponent "%InstallMount%\%%i", "天气应用", "BingWeather"
		if "%Component%" equ "Calculator" call :RemoveWindowsComponent "%InstallMount%\%%i", "计算器应用", "Calculator"
		if "%Component%" equ "Camera" call :RemoveWindowsComponent "%InstallMount%\%%i", "相机应用", "Camera"
		if "%Component%" equ "CommunicationsApps" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 邮件应用", "CommunicationsApps"
		if "%Component%" equ "Cortana" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" call :RemoveWindowsComponent "%InstallMount%\%%i", "Cortana 应用", "Cortana"
		if "%Component%" equ "DesktopAppInstaller" call :RemoveWindowsComponent "%InstallMount%\%%i", "桌面应用安装程序", "DesktopAppInstaller"
		if "%Component%" equ "FeedbackHub" call :RemoveWindowsComponent "%InstallMount%\%%i", "反馈中心应用", "FeedbackHub"
		if "%Component%" equ "GetHelp" call :RemoveWindowsComponent "%InstallMount%\%%i", "获取帮助应用", "GetHelp"
		if "%Component%" equ "Getstarted" call :RemoveWindowsComponent "%InstallMount%\%%i", "使用技巧应用", "Getstarted"
		if "%Component%" equ "HEIFImageExtension" call :RemoveWindowsComponent "%InstallMount%\%%i", "高效图像文件编解码器插件", "HEIFImageExtension"
		if "%Component%" equ "Maps" call :RemoveWindowsComponent "%InstallMount%\%%i", "地图应用", "Maps"
		if "%Component%" equ "Messaging" call :RemoveWindowsComponent "%InstallMount%\%%i", "消息应用", "Messaging"
		if "%Component%" equ "MixedRealityPortal" call :RemoveWindowsComponent "%InstallMount%\%%i", "混合现实门户应用", "MixedRealityPortal"
		if "%Component%" equ "OfficeHub" call :RemoveWindowsComponent "%InstallMount%\%%i", "我的 Office 应用", "OfficeHub"
		if "%Component%" equ "OfficeOneNote" call :RemoveWindowsComponent "%InstallMount%\%%i", "OneNote 应用", "OfficeOneNote"
		if "%Component%" equ "OneConnect" call :RemoveWindowsComponent "%InstallMount%\%%i", "移动套餐应用", "OneConnect"
		if "%Component%" equ "Paint3D" call :RemoveWindowsComponent "%InstallMount%\%%i", "画图 3D 应用", "Paint3D"
		if "%Component%" equ "People" call :RemoveWindowsComponent "%InstallMount%\%%i", "人脉应用", "People"
		if "%Component%" equ "Photos" call :RemoveWindowsComponent "%InstallMount%\%%i", "照片应用", "Photos"
		if "%Component%" equ "Print3D" call :RemoveWindowsComponent "%InstallMount%\%%i", "Print 3D 应用", "Print3D"
		if "%Component%" equ "ScreenSketch" call :RemoveWindowsComponent "%InstallMount%\%%i", "屏幕和草图应用", "ScreenSketch"
		if "%Component%" equ "SkypeApp" call :RemoveWindowsComponent "%InstallMount%\%%i", "Skype 应用", "SkypeApp"
		if "%Component%" equ "SolitaireCollection" call :RemoveWindowsComponent "%InstallMount%\%%i", "Solitaire Collection 应用", "SolitaireCollection"
		if "%Component%" equ "SoundRecorder" call :RemoveWindowsComponent "%InstallMount%\%%i", "录音机应用", "SoundRecorder"
		if "%Component%" equ "StickyNotes" call :RemoveWindowsComponent "%InstallMount%\%%i", "便笺应用", "StickyNotes"
		if "%Component%" equ "VP9VideoExtensions" call :RemoveWindowsComponent "%InstallMount%\%%i", "Google 的 VP9 WebM 视频编解码器插件", "VP9VideoExtensions"
		if "%Component%" equ "WalletService" call :RemoveWindowsComponent "%InstallMount%\%%i", "Microsoft Pay 应用", "WalletService"
		if "%Component%" equ "WebMediaExtensions" call :RemoveWindowsComponent "%InstallMount%\%%i", "Web 媒体扩展插件", "WebMediaExtensions"
		if "%Component%" equ "WebpImageExtensions" call :RemoveWindowsComponent "%InstallMount%\%%i", "Webp 图像扩展插件", "WebpImageExtensions"
		if "%Component%" equ "WindowsStore" call :RemoveWindowsComponent "%InstallMount%\%%i", "Windows 应用商店应用", "WindowsStore"
		if "%Component%" equ "XboxApp" call :RemoveWindowsComponent "%InstallMount%\%%i", "Xbox 应用", "XboxApp"
		if "%Component%" equ "XboxIdentityProvider" call :RemoveWindowsComponent "%InstallMount%\%%i", "Xbox Identity Provider", "XboxIdentityProvider"
		if "%Component%" equ "YourPhone" call :RemoveWindowsComponent "%InstallMount%\%%i", "你的手机应用", "YourPhone"
		if "%Component%" equ "ZuneMusic" call :RemoveWindowsComponent "%InstallMount%\%%i", "Groove 音乐应用", "ZuneMusic"
		if "%Component%" equ "ZuneVideo" if "%ImageBuild%" leq "18363" call :RemoveWindowsComponent "%InstallMount%\%%i", "电影和电视应用", "ZuneVideo"
		if "%Component%" equ "ZuneVideo" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" call :RemoveWindowsComponent "%InstallMount%\%%i", "电影和电视应用", "ZuneVideo"

		if "%Component%" equ "InternetComponents" call :RemoveWindowsComponent "%InstallMount%\%%i", "Internet 组件", "Internet"
		if "%Component%" equ "MultimediaComponents" call :RemoveWindowsComponent "%InstallMount%\%%i", "多媒体组件", "Multimedia"
		if "%Component%" equ "PrivacyComponents" call :RemoveWindowsComponent "%InstallMount%\%%i", "隐私组件", "Privacy"
		if "%Component%" equ "RemotingComponents" call :RemoveWindowsComponent "%InstallMount%\%%i", "远程处理组件", "Remoting"
		if "%Component%" equ "SystemComponents" call :RemoveWindowsComponent "%InstallMount%\%%i", "系统组件", "System"
		if "%Component%" equ "SystemApps" call :RemoveWindowsComponent "%InstallMount%\%%i", "系统应用", "SystemApps"
		if "%Component%" equ "WindowsApps" call :RemoveWindowsComponent "%InstallMount%\%%i", "系统应用", "WindowsApps"
	)
) else (
	:: Internet 组件
	if "%Component%" equ "AdobeFlashForWindows" call :RemoveWindowsComponent "%InstallMount%", "适用于 Windows 的 Adobe Flash", "AdobeFlashForWindows"
	if "%Component%" equ "EdgeChromium" call :RemoveWindowsComponent "%InstallMount%", "Edge Chromium 浏览器", "EdgeChromium"
	if "%Component%" equ "InternetExplorer" call :RemoveWindowsComponent "%InstallMount%", "Internet Explorer", "InternetExplorer"

	:: 多媒体组件
	if "%Component%" equ "FirstLogonAnimation" call :RemoveWindowsComponent "%InstallMount%", "首次登录动画", "FirstLogonAnimation"
	if "%Component%" equ "GameExplorer" call :RemoveWindowsComponent "%InstallMount%", "游戏浏览器", "GameExplorer"
	if "%Component%" equ "SnippingTool" call :RemoveWindowsComponent "%InstallMount%", "截图工具", "SnippingTool"
	if "%Component%" equ "SpeechRecognition" call :RemoveWindowsComponent "%InstallMount%", "语音识别", "SpeechRecognition"
	if "%Component%" equ "WindowsMediaPlayer" call :RemoveWindowsComponent "%InstallMount%", "Windows Media Player", "WindowsMediaPlayer"
	if "%Component%" equ "WindowsPhotoViewer" call :RemoveWindowsComponent "%InstallMount%", "Windows 照片查看器", "WindowsPhotoViewer"
	if "%Component%" equ "WinSAT" call :RemoveWindowsComponent "%InstallMount%", "Windows 系统评估工具", "WinSAT"

	:: 隐私组件
	if "%Component%" equ "AssignedAccess" call :RemoveWindowsComponent "%InstallMount%", "分配的访问权限", "AssignedAccess"
	if "%Component%" equ "CEIP_SQM" call :RemoveWindowsComponent "%InstallMount%", "客户体验改善计划 [CEIP]", "CEIP_SQM"
	if "%Component%" equ "FaceRecognition" call :RemoveWindowsComponent "%InstallMount%", "人脸识别", "FaceRecognition"
	if "%Component%" equ "KernelDebugging" call :RemoveWindowsComponent "%InstallMount%", "内核调试", "KernelDebugging"
	if "%Component%" equ "LocationService" call :RemoveWindowsComponent "%InstallMount%", "定位服务", "LocationService"
	if "%Component%" equ "PicturePassword" call :RemoveWindowsComponent "%InstallMount%", "图片密码", "PicturePassword"
	if "%Component%" equ "PinEnrollment" call :RemoveWindowsComponent "%InstallMount%", "Pin Enrollment", "PinEnrollment"
	if "%Component%" equ "UnifiedTelemetryClient" call :RemoveWindowsComponent "%InstallMount%", "统一遥测客户端 [Asimov]", "UnifiedTelemetryClient"
	if "%Component%" equ "WiFiNetworkManager" call :RemoveWindowsComponent "%InstallMount%", "WiFi Network Manager", "WiFiNetworkManager"
	if "%Component%" equ "WindowsErrorReporting" call :RemoveWindowsComponent "%InstallMount%", "Windows 错误报告", "WindowsErrorReporting"
	if "%Component%" equ "WindowsInsiderHub" call :RemoveWindowsComponent "%InstallMount%", "Windows 会员中心", "WindowsInsiderHub"

	:: 远程处理组件
	if "%Component%" equ "HomeGroup" call :RemoveWindowsComponent "%InstallMount%", "家庭组", "HomeGroup"
	if "%Component%" equ "MultiPointConnector" call :RemoveWindowsComponent "%InstallMount%", "MultiPoint Connector", "MultiPointConnector"
	if "%Component%" equ "RemoteAssistance" call :RemoveWindowsComponent "%InstallMount%", "远程协助", "RemoteAssistance"

	:: 系统组件
	if "%Component%" equ "DeviceLockdown" call :RemoveWindowsComponent "%InstallMount%", "设备锁定 [嵌入式体验]", "DeviceLockdown"
	if "%Component%" equ "EaseOfAccessThemes" call :RemoveWindowsComponent "%InstallMount%", "轻松访问主题", "EaseOfAccessThemes"
	if "%Component%" equ "EasyTransfer" call :RemoveWindowsComponent "%InstallMount%", "轻松传送", "EasyTransfer"
	if "%Component%" equ "FileHistory" call :RemoveWindowsComponent "%InstallMount%", "文件历史记录", "FileHistory"
	if "%Component%" equ "ManualSetup" call :RemoveWindowsManualSetup
	if "%Component%" equ "Paint" call :RemoveWindowsComponent "%InstallMount%", "Microsoft 画图", "Paint"
	if "%Component%" equ "SecurityCenter" call :RemoveWindowsComponent "%InstallMount%", "安全中心", "SecurityCenter"
	if "%Component%" equ "StepsRecorder" call :RemoveWindowsComponent "%InstallMount%", "步骤记录器", "StepsRecorder"
	if "%Component%" equ "SystemRestore" call :RemoveWindowsComponent "%InstallMount%", "系统恢复", "SystemRestore"
	if "%Component%" equ "WindowsBackup" call :RemoveWindowsComponent "%InstallMount%", "Windows 备份", "WindowsBackup"
	if "%Component%" equ "WindowsSubsystemForLinux" call :RemoveWindowsComponent "%InstallMount%", "适用于 Linux 的 Windows 子系统", "WindowsSubsystemForLinux"
	if "%Component%" equ "WindowsToGo" call :RemoveWindowsComponent "%InstallMount%", "Windows To Go", "WindowsToGo"
	if "%Component%" equ "Wordpad" call :RemoveWindowsComponent "%InstallMount%", "写字板", "Wordpad"

	:: 系统应用
	if "%Component%" equ "AADBrokerPlugin" call :RemoveWindowsComponent "%InstallMount%", "Azure Active Directory AppX 代理插件", "AADBrokerPlugin"
	if "%Component%" equ "AssignedAccessLockApp" call :RemoveWindowsComponent "%InstallMount%", "指定访问锁定应用", "AssignedAccessLockApp"
	if "%Component%" equ "BioEnrollment" call :RemoveWindowsComponent "%InstallMount%", "生物注册应用", "BioEnrollment"
	if "%Component%" equ "CallingShellApp" call :RemoveWindowsComponent "%InstallMount%", "Calling Shell 应用", "CallingShellApp"
	if "%Component%" equ "CBSPreview" call :RemoveWindowsComponent "%InstallMount%", "Camera Barcode Scanner", "CBSPreview"
	if "%Component%" equ "ContentDeliveryManager" call :RemoveWindowsComponent "%InstallMount%", "Content Delivery Manager", "ContentDeliveryManager"
	if "%Component%" equ "Cortana" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "18363" call :RemoveWindowsComponent "%InstallMount%", "Cortana、开始菜单和设置搜索应用", "Cortana"
	if "%Component%" equ "ECApp" call :RemoveWindowsComponent "%InstallMount%", "目视控制应用", "ECApp"

	if "%Component%" equ "Edge" (
		call :RemoveWindowsComponent "%InstallMount%", "Edge 开发者工具客户端", "EdgeDevToolsClient"
		call :RemoveWindowsComponent "%InstallMount%", "Edge 浏览器应用", "Edge"
		call :RemoveWindowsComponent "%InstallMount%", "Windows 阅读器 [PDF]", "WindowsReaderPDF"
	)

	if "%Component%" equ "EdgeDevToolsClient" call :RemoveWindowsComponent "%InstallMount%", "Edge 开发者工具客户端", "EdgeDevToolsClient"
	if "%Component%" equ "FileExplorer" call :RemoveWindowsComponent "%InstallMount%", "文件资源管理器应用", "FileExplorer"
	if "%Component%" equ "LockApp" call :RemoveWindowsComponent "%InstallMount%", "锁屏应用", "LockApp"
	if "%Component%" equ "MapControl" call :RemoveWindowsComponent "%InstallMount%", "地图控件", "MapControl"
	if "%Component%" equ "NarratorQuickStart" call :RemoveWindowsComponent "%InstallMount%", "Narrator QuickStart", "NarratorQuickStart"
	if "%Component%" equ "OneDrive" call :RemoveWindowsComponent "%InstallMount%", "OneDrive 桌面客户端", "OneDrive"
	if "%Component%" equ "ParentalControls" call :RemoveWindowsComponent "%InstallMount%", "家长控制应用", "ParentalControls"
	if "%Component%" equ "PeopleExperienceHost" call :RemoveWindowsComponent "%InstallMount%", "People Experience 主机", "PeopleExperienceHost"
	if "%Component%" equ "PPIProjection" if "%ImageBuild%" geq "17763" if "%ImageBuild%" leq "18363" call :RemoveWindowsComponent "%InstallMount%", "连接应用", "PPIProjection"
	if "%Component%" equ "QuickAssist" call :RemoveWindowsComponent "%InstallMount%", "快速助手应用", "QuickAssist"
	if "%Component%" equ "RetailDemoContent" call :RemoveWindowsComponent "%InstallMount%", "零售演示内容", "RetailDemoContent"
	if "%Component%" equ "SecureAssessmentBrowser" call :RemoveWindowsComponent "%InstallMount%", "Take Test 应用", "SecureAssessmentBrowser"
	if "%Component%" equ "SettingSync" call :RemoveWindowsComponent "%InstallMount%", "设置同步", "SettingSync"
	if "%Component%" equ "SkypeORTC" call :RemoveWindowsComponent "%InstallMount%", "Skype ORTC", "SkypeORTC"
	if "%Component%" equ "SmartScreen" call :RemoveWindowsComponent "%InstallMount%", "SmartScreen 应用", "SmartScreen"
	if "%Component%" equ "Win32WebViewHost" call :RemoveWindowsComponent "%InstallMount%", "Win32 WebView 主机", "Win32WebViewHost"
	if "%Component%" equ "WindowsDefender" call :RemoveWindowsComponent "%InstallMount%", "Windows Defender 应用", "WindowsDefender"
	if "%Component%" equ "WindowsMixedReality" call :RemoveWindowsComponent "%InstallMount%", "Windows 混合现实", "WindowsMixedReality"
	if "%Component%" equ "WindowsReaderPDF" call :RemoveWindowsComponent "%InstallMount%", "Windows 阅读器 [PDF]", "WindowsReaderPDF"
	if "%Component%" equ "XboxGameCallableUI" call :RemoveWindowsComponent "%InstallMount%", "Xbox Game Callable UI", "XboxGameCallableUI"

	:: Windows 应用
	if "%Component%" equ "3DViewer" call :RemoveWindowsComponent "%InstallMount%", "混合现实查看器应用", "3DViewer"
	if "%Component%" equ "AdvertisingXaml" call :RemoveWindowsComponent "%InstallMount%", "Advertising Xaml", "AdvertisingXaml"
	if "%Component%" equ "Alarms" call :RemoveWindowsComponent "%InstallMount%", "闹钟和时钟应用", "Alarms"
	if "%Component%" equ "BingWeather" call :RemoveWindowsComponent "%InstallMount%", "天气应用", "BingWeather"
	if "%Component%" equ "Calculator" call :RemoveWindowsComponent "%InstallMount%", "计算器应用", "Calculator"
	if "%Component%" equ "Camera" call :RemoveWindowsComponent "%InstallMount%", "相机应用", "Camera"
	if "%Component%" equ "CommunicationsApps" call :RemoveWindowsComponent "%InstallMount%", "Windows 邮件应用", "CommunicationsApps"
	if "%Component%" equ "Cortana" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" call :RemoveWindowsComponent "%InstallMount%", "Cortana 应用", "Cortana"
	if "%Component%" equ "DesktopAppInstaller" call :RemoveWindowsComponent "%InstallMount%", "桌面应用安装程序", "DesktopAppInstaller"
	if "%Component%" equ "FeedbackHub" call :RemoveWindowsComponent "%InstallMount%", "反馈中心应用", "FeedbackHub"
	if "%Component%" equ "GetHelp" call :RemoveWindowsComponent "%InstallMount%", "获取帮助应用", "GetHelp"
	if "%Component%" equ "Getstarted" call :RemoveWindowsComponent "%InstallMount%", "使用技巧应用", "Getstarted"
	if "%Component%" equ "HEIFImageExtension" call :RemoveWindowsComponent "%InstallMount%", "高效图像文件编解码器插件", "HEIFImageExtension"
	if "%Component%" equ "Maps" call :RemoveWindowsComponent "%InstallMount%", "地图应用", "Maps"
	if "%Component%" equ "Messaging" call :RemoveWindowsComponent "%InstallMount%", "消息应用", "Messaging"
	if "%Component%" equ "MixedRealityPortal" call :RemoveWindowsComponent "%InstallMount%", "混合现实门户应用", "MixedRealityPortal"
	if "%Component%" equ "OfficeHub" call :RemoveWindowsComponent "%InstallMount%", "我的 Office 应用", "OfficeHub"
	if "%Component%" equ "OfficeOneNote" call :RemoveWindowsComponent "%InstallMount%", "OneNote 应用", "OfficeOneNote"
	if "%Component%" equ "OneConnect" call :RemoveWindowsComponent "%InstallMount%", "移动套餐应用", "OneConnect"
	if "%Component%" equ "Paint3D" call :RemoveWindowsComponent "%InstallMount%", "画图 3D 应用", "Paint3D"
	if "%Component%" equ "People" call :RemoveWindowsComponent "%InstallMount%", "人脉应用", "People"
	if "%Component%" equ "Photos" call :RemoveWindowsComponent "%InstallMount%", "照片应用", "Photos"
	if "%Component%" equ "Print3D" call :RemoveWindowsComponent "%InstallMount%", "Print 3D 应用", "Print3D"
	if "%Component%" equ "ScreenSketch" call :RemoveWindowsComponent "%InstallMount%", "屏幕和草图应用", "ScreenSketch"
	if "%Component%" equ "SkypeApp" call :RemoveWindowsComponent "%InstallMount%", "Skype 应用", "SkypeApp"
	if "%Component%" equ "SolitaireCollection" call :RemoveWindowsComponent "%InstallMount%", "Solitaire Collection 应用", "SolitaireCollection"
	if "%Component%" equ "SoundRecorder" call :RemoveWindowsComponent "%InstallMount%", "录音机应用", "SoundRecorder"
	if "%Component%" equ "StickyNotes" call :RemoveWindowsComponent "%InstallMount%", "便笺应用", "StickyNotes"
	if "%Component%" equ "VP9VideoExtensions" call :RemoveWindowsComponent "%InstallMount%", "Google 的 VP9 WebM 视频编解码器插件", "VP9VideoExtensions"
	if "%Component%" equ "WalletService" call :RemoveWindowsComponent "%InstallMount%", "Microsoft Pay 应用", "WalletService"
	if "%Component%" equ "WebMediaExtensions" call :RemoveWindowsComponent "%InstallMount%", "Web 媒体扩展插件", "WebMediaExtensions"
	if "%Component%" equ "WebpImageExtensions" call :RemoveWindowsComponent "%InstallMount%", "Webp 图像扩展插件", "WebpImageExtensions"
	if "%Component%" equ "WindowsStore" call :RemoveWindowsComponent "%InstallMount%", "Windows 应用商店应用", "WindowsStore"
	if "%Component%" equ "XboxApp" call :RemoveWindowsComponent "%InstallMount%", "Xbox 应用", "XboxApp"
	if "%Component%" equ "XboxIdentityProvider" call :RemoveWindowsComponent "%InstallMount%", "Xbox Identity Provider", "XboxIdentityProvider"
	if "%Component%" equ "YourPhone" call :RemoveWindowsComponent "%InstallMount%", "你的手机应用", "YourPhone"
	if "%Component%" equ "ZuneMusic" call :RemoveWindowsComponent "%InstallMount%", "Groove 音乐应用", "ZuneMusic"
	if "%Component%" equ "ZuneVideo" if "%ImageBuild%" leq "18363" call :RemoveWindowsComponent "%InstallMount%", "电影和电视应用", "ZuneVideo"
	if "%Component%" equ "ZuneVideo" if "%ImageBuild%" geq "19041" if "%ImageBuild%" leq "19042" call :RemoveWindowsComponent "%InstallMount%", "电影和电视应用", "ZuneVideo"

	if "%Component%" equ "InternetComponents" call :RemoveWindowsComponent "%InstallMount%", "Internet 组件", "Internet"
	if "%Component%" equ "MultimediaComponents" call :RemoveWindowsComponent "%InstallMount%", "多媒体组件", "Multimedia"
	if "%Component%" equ "PrivacyComponents" call :RemoveWindowsComponent "%InstallMount%", "隐私组件", "Privacy"
	if "%Component%" equ "RemotingComponents" call :RemoveWindowsComponent "%InstallMount%", "远程处理组件", "Remoting"
	if "%Component%" equ "SystemComponents" call :RemoveWindowsComponent "%InstallMount%", "系统组件", "System"
	if "%Component%" equ "SystemApps" call :RemoveWindowsComponent "%InstallMount%", "系统应用", "SystemApps"
	if "%Component%" equ "WindowsApps" call :RemoveWindowsComponent "%InstallMount%", "Windows 应用", "WindowsApps"
)
echo.-------------------------------------------------------------------------------
echo.####移除 Windows 组件功能已完成################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Component=
endlocal

:: 返回到主菜单。
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 移除 Windows 手动安装程序模块
::-------------------------------------------------------------------------------------------
:RemoveWindowsManualSetup

echo.-------------------------------------------------------------------------------
echo.正在移除 Windows 手动安装程序功能……
echo.-------------------------------------------------------------------------------
echo.
		
:: 移除 Windows 手动安装程序功能文件和文件夹
echo.请稍侯，正在删除 Windows 手动安装程序文件和文件夹……

call :RemoveFile "%DVD%\autorun.inf"
call :RemoveFile "%DVD%\setup.exe"
call :RemoveFile "%DVD%\*.dll"
call :RemoveFolder "%DVD%\ca"
call :RemoveFolder "%DVD%\NanoServer"
call :RemoveFolder "%DVD%\support"
call :RemoveFolder "%DVD%\upgrade"
call :RemoveFolder "%DVD%\sources\dlmanifests"
call :RemoveFolder "%DVD%\sources\etwproviders"
call :RemoveFolder "%DVD%\sources\inf"
call :RemoveFolder "%DVD%\sources\hwcompat"
call :RemoveFolder "%DVD%\sources\migration"
call :RemoveFolder "%DVD%\sources\replacementmanifests"
call :RemoveFolder "%DVD%\sources\servicing"
call :RemoveFolder "%DVD%\sources\servicingstackmisc"
call :RemoveFolder "%DVD%\sources\sxs"
call :RemoveFolder "%DVD%\sources\vista"
call :RemoveFolder "%DVD%\sources\xp"

if exist "%DVD%\sources\%ImageDefaultLanguage%\setup.exe.mui" move /y "%DVD%\sources\%ImageDefaultLanguage%\setup.exe.mui" "%DVD%" >nul
if exist "%DVD%\sources\EI.CFG" move /y "%DVD%\sources\EI.CFG" "%DVD%" >nul
if exist "%DVD%\sources\*.clg" move /y "%DVD%\sources\*.clg" "%DVD%" >nul
if exist "%DVD%\sources\gatherosstate.exe" move /y "%DVD%\sources\gatherosstate.exe" "%DVD%" >nul
if exist "%DVD%\sources\setup.exe" move /y "%DVD%\sources\setup.exe" "%DVD%" >nul
if exist "%DVD%\sources\lang.ini" move /y "%DVD%\sources\lang.ini" "%DVD%" >nul
if exist "%DVD%\sources\pid.txt" move /y "%DVD%\sources\pid.txt" "%DVD%" >nul

call :RemoveFile "%DVD%\sources\%ImageDefaultLanguage%\*.adml"
call :RemoveFile "%DVD%\sources\%ImageDefaultLanguage%\*.mui"
call :RemoveFile "%DVD%\sources\%ImageDefaultLanguage%\*.rtf"
call :RemoveFile "%DVD%\sources\%ImageDefaultLanguage%\*.txt"
call :RemoveFile "%DVD%\sources\*.dll"
call :RemoveFile "%DVD%\sources\*.gif"
call :RemoveFile "%DVD%\sources\*.xsl"
call :RemoveFile "%DVD%\sources\*.bmp"
call :RemoveFile "%DVD%\sources\*.mof"
call :RemoveFile "%DVD%\sources\*.ini"
call :RemoveFile "%DVD%\sources\*.cer"
call :RemoveFile "%DVD%\sources\*.exe"
call :RemoveFile "%DVD%\sources\*.sdb"
call :RemoveFile "%DVD%\sources\*.txt"
call :RemoveFile "%DVD%\sources\*.nls"
call :RemoveFile "%DVD%\sources\*.xml"
call :RemoveFile "%DVD%\sources\*.cat"
call :RemoveFile "%DVD%\sources\*.inf"
call :RemoveFile "%DVD%\sources\*.sys"
call :RemoveFile "%DVD%\sources\*.bin"
call :RemoveFile "%DVD%\sources\*.ait"
call :RemoveFile "%DVD%\sources\*.admx"
call :RemoveFile "%DVD%\sources\*.dat"
call :RemoveFile "%DVD%\sources\*.ttf"
call :RemoveFile "%DVD%\sources\*.cfg"
call :RemoveFile "%DVD%\sources\*.xsd"
call :RemoveFile "%DVD%\sources\*.rtf"
call :RemoveFile "%DVD%\sources\*.xrm-ms"

if exist "%DVD%\setup.exe.mui" move /y "%DVD%\setup.exe.mui" "%DVD%\sources\%ImageDefaultLanguage%" >nul
if exist "%DVD%\EI.CFG" move /y "%DVD%\EI.CFG" "%DVD%\sources" >nul
if exist "%DVD%\*.clg" move /y "%DVD%\*.clg" "%DVD%\sources" >nul
if exist "%DVD%\gatherosstate.exe" move /y "%DVD%\gatherosstate.exe" "%DVD%\sources" >nul
if exist "%DVD%\setup.exe" move /y "%DVD%\setup.exe" "%DVD%\sources" >nul
if exist "%DVD%\lang.ini" move /y "%DVD%\lang.ini" "%DVD%\sources" >nul
if exist "%DVD%\pid.txt" move /y "%DVD%\pid.txt" "%DVD%\sources" >nul
echo.
echo.删除 Windows 手动安装程序文件和文件夹已完成……
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 使用应用列表移除默认 Metro 应用模块
::-------------------------------------------------------------------------------------------
:RemoveWindowsAppsList

setlocal

set "RemoveAppsList=%Lists%\RemoveAppsList.txt"

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 使用应用列表移除默认 Metro 应用
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始使用应用列表移除默认 Metro 应用####################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在使用应用列表移除默认 Metro 应用########################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (
		if not "%ImageIndexNo%" gtr "9" echo.#########################[Install.wim，索引 ：%%i]###############################
		if "%ImageIndexNo%" gtr "9" echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.	

		for /f %%z IN ('"type %RemoveAppsList%" 2^>nul') do (
			call :RemoveProvisionedAppxPackage "%InstallMount%\%%i", %%z, %%z
			
			if "%%z" equ "Microsoft.3DBuilder" (
				:: 安装映像注册表
				call :MountImageRegistry "%InstallMount%\%%i"
	
				:: 移除“使用 3D Builder 进行 3D 打印”选项右键单击上下文菜单注册表项
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.bmp\Shell\T3D Print" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jpg\Shell\T3D Print" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.png\Shell\T3D Print" /f >nul 2>&1
				
				:: 卸载映像注册表
				call :UnMountImageRegistry
			)
			
			if "%%z" equ "Microsoft.MSPaint" (
				:: 安装映像注册表
				call :MountImageRegistry "%InstallMount%\%%i"
	
				:: 移除“使用画图 3D 进行编辑”选项右键单击上下文菜单注册表项
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.3mf\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.bmp\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.fbx\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.gif\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jfif\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jpe\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jpeg\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jpg\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.png\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.tif\Shell\3D Edit" /f >nul 2>&1
				Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.tiff\Shell\3D Edit" /f >nul 2>&1

				:: 卸载映像注册表
				call :UnMountImageRegistry
			)
						
			if "%%z" equ "Microsoft.Print3D" if "%ImageBuild%" geq "16299"  (
				:: 安装映像注册表
				call :MountImageRegistry "%InstallMount%\%%i"
				
				:: 从 Windows 资源管理器导航窗格中删除 3D 对象部分
				Reg delete "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" /f >nul 2>&1
				if "%ImageArchitecture%" equ "x64" Reg delete "HKLM\TK_SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" /f >nul 2>&1
					
				:: 卸载映像注册表
				call :UnMountImageRegistry
			)

			if "%%z" equ "Microsoft.Microsoft3DViewer" if "%ImageBuild%" geq "16299"  (
				:: 安装映像注册表
				call :MountImageRegistry "%InstallMount%\%%i"
				
				:: 从 Windows 资源管理器导航窗格中删除 3D 对象部分
				Reg delete "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" /f >nul 2>&1
				if "%ImageArchitecture%" equ "x64" Reg delete "HKLM\TK_SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" /f >nul 2>&1
					
				:: 卸载映像注册表
				call :UnMountImageRegistry
			)
		)
	)
) else (
	for /f %%z IN ('"type %RemoveAppsList%" 2^>nul') do (
		call :RemoveProvisionedAppxPackage "%InstallMount%", %%z, %%z
		
		if "%%z" equ "Microsoft.3DBuilder" (
			:: 安装映像注册表
			call :MountImageRegistry "%InstallMount%"
	
			:: 移除“使用 3D Builder 进行 3D 打印”选项右键单击上下文菜单注册表项
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.bmp\Shell\T3D Print" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jpg\Shell\T3D Print" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.png\Shell\T3D Print" /f >nul 2>&1
				
			:: 卸载映像注册表
			call :UnMountImageRegistry
		)
			
		if "%%z" equ "Microsoft.MSPaint" (
			:: 安装映像注册表
			call :MountImageRegistry "%InstallMount%"
	
			:: 移除“使用画图 3D 进行编辑”选项右键单击上下文菜单注册表项
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.3mf\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.bmp\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.fbx\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.gif\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jfif\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jpe\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jpeg\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.jpg\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.png\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.tif\Shell\3D Edit" /f >nul 2>&1
			Reg delete "HKLM\TK_SOFTWARE\Classes\SystemFileAssociations\.tiff\Shell\3D Edit" /f >nul 2>&1

			:: 卸载映像注册表
			call :UnMountImageRegistry
		)

		if "%%z" equ "Microsoft.Print3D" if "%ImageBuild%" geq "16299"  (
			:: 安装映像注册表
			call :MountImageRegistry "%InstallMount%"
				
			:: 从 Windows 资源管理器导航窗格中删除 3D 对象部分
			Reg delete "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" /f >nul 2>&1
			if "%ImageArchitecture%" equ "x64" Reg delete "HKLM\TK_SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" /f >nul 2>&1
				
			:: 卸载映像注册表
			call :UnMountImageRegistry
		)

		if "%%z" equ "Microsoft.Microsoft3DViewer" if "%ImageBuild%" geq "16299"  (
			:: 安装映像注册表
			call :MountImageRegistry "%InstallMount%"
			
			:: 从 Windows 资源管理器导航窗格中删除 3D 对象部分
			Reg delete "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" /f >nul 2>&1
			if "%ImageArchitecture%" equ "x64" Reg delete "HKLM\TK_SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" /f >nul 2>&1
				
			:: 卸载映像注册表
			call :UnMountImageRegistry
		)
	)
)
echo.-------------------------------------------------------------------------------
echo.####使用应用列表移除默认 Metro 应用已完成######################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set RemoveAppsList=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 使用软件包列表移除 Windows 组件模块
::-------------------------------------------------------------------------------------------
:RemoveWindowsComponentsList

if "%IsDialogsEnabled%" equ "Yes" (
	cls
	echo.===============================================================================
	echo.                  MSMG 工具箱 - 使用软件包列表移除 Windows 组件
	echo.===============================================================================
	echo.
	echo.
	echo.
	echo.                                警         告
	echo.                                =============
	echo.
	echo.   在没有进行适当测试的情况下任意移除软件包，有可能会破坏操作系统和\或其相应
	echo.   功能。
	echo.
	echo.   在当将软件包添加到 RemovePkgsList.txt 时，仅添加父软件包名称，不包括它的
	echo.   语言包或子软件包。
	echo.   
	echo.
	echo.   例如：WindowsDefender ^(ToolKitHelper.exe 方式^)
	echo.   例如：Windows-Defender-Client-Package ^(DISM 方式^)
	echo.
	echo.   若要关闭此警告对话框，请在工具 -^> 选项菜单中选择禁用对话框
	echo.
	echo.===============================================================================
	echo.
	choice /C:YN /N /M "你想要继续吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 goto :MainMenu
)

setlocal

set "RemovePkgsList=%Lists%\RemovePkgsList.txt"
set RemovalMethod=

cls
echo.===============================================================================
echo.               MSMG 工具箱 - 使用软件包列表移除 Windows 组件菜单
echo.===============================================================================
echo.
echo.  [1]   使用软件包列表移除 Windows 组件 ^(DISM 方式^)
echo. 
echo.  [2]   使用软件包列表移除 Windows 组件 ^(ToolKitHelper 方式^)
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:12X /N /M "请输入你的选项 ："
if errorlevel 3 goto :MainMenu
if errorlevel 2 set "RemovalMethod=ToolKitHelper"
if errorlevel 1 set "RemovalMethod=DISM"

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 使用软件包列表移除 Windows 组件
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始使用软件包列表移除 Windows 组件####################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在使用软件包列表移除 Windows 组件########################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.	

		if "%RemovalMethod%" == "DISM" (
			for /f %%z IN ('"type %RemovePkgsList%" 2^>nul') do (
				call :RemoveLockedPackage "%InstallMount%\%%i", %%z, %%z
			)
		)

		if "%RemovalMethod%" == "ToolKitHelper" (
			%ToolKitHelper% "%InstallMount%\%%i" "%RemovePkgsList%"
			echo.
		)
	)
) else (
	if "%RemovalMethod%" == "DISM" (
		echo.
		for /f %%z IN ('"type %RemovePkgsList%" 2^>nul') do (
			call :RemoveLockedPackage "%InstallMount%", %%z, %%z
		)
	)

	if "%RemovalMethod%" == "ToolKitHelper" (
		%ToolKitHelper% "%InstallMount%" "%RemovePkgsList%"
		echo.
	)
)
echo.-------------------------------------------------------------------------------
echo.####使用软件包列表移除 Windows 组件已完成######################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set RemovePkgsList=
set RemovalMethod=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 使用功能列表启用 Windows 功能模块
::-------------------------------------------------------------------------------------------
:EnableFeatures

setlocal

set "FeaturesList=%Lists%\EnableFeaturesList.txt"

cls
echo.===============================================================================
echo.                 MSMG 工具箱 - 使用功能列表启用 Windows 功能
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始使用功能列表启用 Windows 功能######################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在使用功能列表启用 Windows 功能##########################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.

		for /f %%z IN ('"type %FeaturesList%" 2^>nul') do (
			echo.-------------------------------------------------------------------------------
			echo.正在启用 Windows 功能 - [%%z]
			echo.-------------------------------------------------------------------------------
			call :EnableFeature "%InstallMount%\%%i" %%z
		)
	)
) else (
	for /f %%z IN ('"type %FeaturesList%" 2^>nul') do (
		echo.-------------------------------------------------------------------------------
		echo.正在启用 Windows 功能 - [%%z]
		echo.-------------------------------------------------------------------------------
		call :EnableFeature "%InstallMount%" %%z
	)
)
echo.-------------------------------------------------------------------------------
echo.####使用功能列表启用 Windows 功能已完成########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set FeaturesList=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
::-------------------------------------------------------------------------------------------
:: 使用功能列表禁用 Windows 功能模块
::-------------------------------------------------------------------------------------------
:DisableFeatures

setlocal

set "FeaturesList=%Lists%\DisableFeaturesList.txt"

cls
echo.===============================================================================
echo.                 MSMG 工具箱 - 使用功能列表禁用 Windows 功能
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始使用功能列表禁用 Windows 功能######################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在使用功能列表禁用 Windows 功能##########################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.

		for /f %%z IN ('"type %FeaturesList%" 2^>nul') do (
			echo.-------------------------------------------------------------------------------
			echo.正在禁用 Windows 功能 - [%%z]
			echo.-------------------------------------------------------------------------------
			call :DisableFeature "%InstallMount%\%%i" %%z
		)
	)
) else (
	for /f %%z IN ('"type %FeaturesList%" 2^>nul') do (
		echo.-------------------------------------------------------------------------------
		echo.正在禁用 Windows 功能 - [%%z]
		echo.-------------------------------------------------------------------------------
		call :DisableFeature "%InstallMount%" %%z
	)
)
echo.-------------------------------------------------------------------------------
echo.####使用功能列表禁用 Windows 功能已完成########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set FeaturesList=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 从 XML 文件导入自定义默认 Metro 应用关联的模块
::-------------------------------------------------------------------------------------------
:ImportMetroAppsAssociation

setlocal

set "CustomAppsAssociationXML=%XMLs%\%SelectedSourceOS%_CustomAppsAssociation.xml"

cls
echo.===============================================================================
echo.           MSMG 工具箱 - 从 XML 文件导入自定义默认 Metro 应用关联
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始从 XML 文件导入自定义默认 Metro 应用关联###########################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在从 XML 文件导入自定义默认 Metro 应用关联###############################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################

		call :ImportDefaultAppAssociations "%InstallMount%\%%i", "%CustomAppsAssociationXML%"
	)
) else (
	call :ImportDefaultAppAssociations "%InstallMount%", "%CustomAppsAssociationXML%"
)
echo.
echo.-------------------------------------------------------------------------------
echo.####从 XML 文件导入自定义默认 Metro 应用关联已完成#############################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set CustomAppsAssociationXML=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 导出默认 Metro 应用关联到 XML 文件模块
::-------------------------------------------------------------------------------------------
:ExportMetroAppsAssociation

setlocal

set "DefaultMetroAppsAssociationXML=%XMLs%\%SelectedSourceOS%_DefaultAppsAssociation.xml"

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 导出默认 Metro 应用关联到 XML 文件
echo.===============================================================================
echo.

:: 检查多重索引维护模式是否已启用
if "%ImageIndexNo%" equ "*" (
	echo.当多重索引维护模式已启用时，此功能不可用……
	echo.
	echo.请使用单一的索引重新选择源文件……
	goto :Stop
)

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始导出默认 Metro 应用关联到 XML 文件#################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在检查默认 Metro 应用关联################################################
echo.-------------------------------------------------------------------------------
echo.
%DISM% /Image:"%InstallMount%" /Get-DefaultAppAssociations | findstr /c:"file could not be" >nul
if errorlevel 1 (
	echo.已找到默认 Metro 应用关联 XML 文件……
	echo.
	echo.-------------------------------------------------------------------------------
	echo.####正在导出默认 Metro 应用关联 XML 文件#######################################
	echo.-------------------------------------------------------------------------------
	echo.
	call :RemoveFile "%DefaultMetroAppsAssociationXML%"
	echo.正在导出默认 Metro 应用关联到 XML 文件……
	%DISM% /Image:"%InstallMount%" /Get-DefaultAppAssociations | findstr "<" >> "%DefaultMetroAppsAssociationXML%"
	echo.
	echo.-------------------------------------------------------------------------------
	echo.####导出默认 Metro 应用关联 XML 文件已完成#####################################
	echo.-------------------------------------------------------------------------------
	goto :Stop
)
if not errorlevel 1 (
	echo.默认 Metro 应用关联 XML 文件是空的……
	echo.
	echo.-------------------------------------------------------------------------------
	echo.####导出默认 Metro 应用关联 XML 文件已停止#####################################
	echo.-------------------------------------------------------------------------------
	goto :Stop
)

:Stop
echo.
echo.===============================================================================
echo.
pause

set DefaultMetroAppsAssociationXML=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 移除默认 Metro 应用关联模块
::-------------------------------------------------------------------------------------------
:RemoveMetroAppsAssociation

setlocal

cls
echo.===============================================================================
echo.                  MSMG 工具箱 - 移除默认 Metro 应用关联
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构。
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始移除默认 Metro 应用关联############################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	echo.
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####正在检查默认 Metro 应用关联################################################
		echo.-------------------------------------------------------------------------------
		echo.
		%DISM% /Image:"%InstallMount%\%%i" /Get-DefaultAppAssociations | findstr /c:"file could not be" >nul
		if errorlevel 1 (
			echo.已找到默认 Metro 应用关联 XML 文件……
			echo.
			echo.-------------------------------------------------------------------------------
			echo.正在移除默认 Metro 应用关联……
			echo.-------------------------------------------------------------------------------
			call :RemoveDefaultAppAssociations "%InstallMount%\%%i"
			echo.
			if "%%i" equ "%ImageCount%" (
				echo.-------------------------------------------------------------------------------
				echo.####移除默认 Metro 应用关联已完成##############################################
				echo.-------------------------------------------------------------------------------
				echo.
			)
		) else (
			echo.默认 Metro 应用关联已经被移除……
			echo.
			echo.正在跳过移除默认 Metro 应用关联……
			echo.
			if "%%i" equ "%ImageCount%" (
				echo.-------------------------------------------------------------------------------
				echo####移除默认 Metro 应用关联已停止##############################################
				echo.-------------------------------------------------------------------------------
				echo.
			)
		)
	)
) else (
	echo.####正在检查默认 Metro 应用关联################################################
	echo.-------------------------------------------------------------------------------
	echo.
	%DISM% /Image:"%InstallMount%" /Get-DefaultAppAssociations | findstr /c:"file could not be" >nul
	if errorlevel 1 (
		echo.已找到默认 Metro 应用关联 XML 文件……
		echo.
		echo.-------------------------------------------------------------------------------
		echo.正在移除默认 Metro 应用关联……
		echo.-------------------------------------------------------------------------------
		call :RemoveDefaultAppAssociations "%InstallMount%"
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####移除默认 Metro 应用关联已完成##############################################
		echo.-------------------------------------------------------------------------------
		echo.
		goto :Stop
	) else (
		echo.默认 Metro 应用关联已经被移除……
		echo.
		echo.-------------------------------------------------------------------------------
		echo####移除默认 Metro 应用关联已停止##############################################
		echo.-------------------------------------------------------------------------------
		echo.
		goto :Stop
	)
)
:Stop
echo.===============================================================================
echo.
pause

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 从 XML 文件合并自定义开始菜单布局模块
::-------------------------------------------------------------------------------------------
:ImportStartMenuLayout

setlocal

set "CustomStartMenuLayoutXML=%XMLs%\%SelectedSourceOS%_CustomStartMenuLayout.xml"

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 从 XML 文件合并自定义开始菜单布局
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始从 XML 文件合并自定义开始菜单布局##################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在从 XML 文件合并自定义开始菜单布局######################################
echo.-------------------------------------------------------------------------------
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.
		echo.正在复制自定义开始菜单布局……
		copy %CustomStartMenuLayoutXML% "%InstallMount%\%%i\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.xml" >nul
		call :RemoveFolder "%InstallMount%\%%i\Users\Default\AppData\Local\TileDataLayer"
	)
) else (
	echo.
	echo.正在复制自定义开始菜单布局……
	copy %CustomStartMenuLayoutXML% "%InstallMount%\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.xml" >nul
	call :RemoveFolder "%InstallMount%\Users\Default\AppData\Local\TileDataLayer"
)
echo.
echo.-------------------------------------------------------------------------------
echo.####从 XML 文件合并自定义开始菜单布局已完成####################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set CustomStartMenuLayoutXML=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 从注册表文件合并自定义注册表设置的模块
::-------------------------------------------------------------------------------------------
:ImportCustomRegistry

setlocal

cls
echo.===============================================================================
echo.               MSMG 工具箱 - 从注册表文件合并自定义注册表设置
echo.===============================================================================
echo.

:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

set "CustomRegistry=%CustomRegistry%\%SelectedSourceOS%\%ImageArchitecture%"

:: 检查自定义注册表文件包文件是否存在
for /f %%i in ('dir /b /a:-d "%CustomRegistry%\*.reg" 2^>nul ^| find /v /c ""') do (
	if "%%i" equ "0" (
		echo.自定义注册表设置文件夹是空的……
		echo.
		echo.请将注册表文件复制到 ^<Custom\Registry\%SelectedSourceOS%\%ImageArchitecture%^> 文件夹……
		goto :Stop
	)
)

echo.-------------------------------------------------------------------------------
echo.####正在开始从注册表文件合并自定义注册表设置###################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
echo.####正在处理自定义注册表设置文件###############################################
echo.-------------------------------------------------------------------------------
echo.
echo.正在使自定义注册表与工具箱的映像注册表兼容……
call :RemoveFolder "%Temp%\CustomRegistry"
call :CreateFolder "%Temp%\CustomRegistry"
PowerShell -Executionpolicy Bypass -File "%Bin%\ConvertReg.ps1" "%CustomRegistry%" "%Temp%\CustomRegistry"
echo.
echo.-------------------------------------------------------------------------------
echo.####正在合并自定义注册表设置文件###############################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.		
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"
		echo.

		for /f "tokens=*" %%z in ('"dir /b "%Temp%\CustomRegistry\*.reg"" 2^>nul') do (
			echo.正在合并 [%%z] 到映像注册表……
			call :ImportRegistry2Image "%Temp%\CustomRegistry\%%z"
		)

		echo.
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
	)
) else (
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"
	echo.

	for /f "tokens=*" %%z in ('"dir /b "%Temp%\CustomRegistry\*.reg"" 2^>nul') do (
		echo.正在合并 [%%z] 到映像注册表……
		call :ImportRegistry2Image "%Temp%\CustomRegistry\%%z"
	)

	echo.
	echo.正在卸载映像注册表……
	call :UnMountImageRegistry
)

call :RemoveFolder "%Temp%\CustomRegistry"
echo.
echo.-------------------------------------------------------------------------------
echo.####从注册表文件合并自定义注册表设置已完成#####################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set CustomRegistry=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 应用调整菜单模块
::-------------------------------------------------------------------------------------------
:ApplyTweaksMenu

setlocal

set Tweak=

cls
echo.===============================================================================
echo.                         MSMG 工具箱 - 应用调整菜单
echo.===============================================================================
echo.

if "%SelectedSourceOS%" equ "w81" (
	echo.  [A]   禁止通过 Windows 更新自动更新驱动
	echo.  [B]   禁用自动下载并安装第三方应用
	echo.  [C]   禁用 Windows Defender
	echo.  [D]   禁用自动执行 Windows 升级
	echo.  [E]   禁用 Windows 更新
	echo.  [F]   强制让 .NET 程序使用最新的 .NET Framework
	echo.  [G]   启用 Windows 照片查看器
	echo.  [H]   启用 Fraunhofer MP3 Professional Codec
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHX /N /M "请输入你的选项 ："
	if errorlevel 9 goto :CustomizeMenu
	if errorlevel 8 set "Tweak=EnableFMP3ProCodec"
	if errorlevel 7 set "Tweak=EnablePhotoViewer"
	if errorlevel 6 set "Tweak=ForceLatestNetFramework"
	if errorlevel 5 set "Tweak=DisableWindowsUpdate"
	if errorlevel 4 set "Tweak=DisableWindowsUpgrade"
	if errorlevel 3 set "Tweak=DisableWindowsDefender"
	if errorlevel 2 set "Tweak=Disable3RDPartyApps"
	if errorlevel 1 set "Tweak=DisableDriversUpdates"
)

if "%SelectedSourceOS%" equ "w10" (
	echo.  [A]   禁用 Cortana 应用
	echo.  [B]   隐藏任务栏任务视图图标
	echo.  [C]   禁止通过 Windows 更新自动更新驱动
	echo.  [D]   禁用自动下载并安装第三方应用
	echo.  [E]   禁用 Windows Defender
	echo.  [F]   禁用自动执行 Windows 升级
	echo.  [G]   禁用 Windows 更新
	echo.  [H]   禁用 Microsoft 用于进行 Windows 更新保留的存储空间
	echo.  [I]   强制让 .NET 程序使用最新的 .NET Framework
	echo.  [J]   启用 Windows 照片查看器
	echo.  [K]   启用 Fraunhofer MP3 Professional Codec
	echo.  [L]   使用完整 ResetBase 启用 DISM 映像清理
	echo.
	echo.
	echo.
	echo.  [X]   返回
	echo.
	echo.===============================================================================
	echo.
	choice /C:ABCDEFGHIJKLX /N /M "请输入你的选项 ："
	if errorlevel 13 goto :CustomizeMenu
	if errorlevel 12 set "Tweak=EnableFullResetBase"
	if errorlevel 11 set "Tweak=EnableFMP3ProCodec"
	if errorlevel 10 set "Tweak=EnablePhotoViewer"
	if errorlevel 9  set "Tweak=ForceLatestNetFramework"
	if errorlevel 8  set "Tweak=DisableReservedStorage"
	if errorlevel 7  set "Tweak=DisableWindowsUpdate"
	if errorlevel 6  set "Tweak=DisableWindowsUpgrade"
	if errorlevel 5  set "Tweak=DisableWindowsDefender"
	if errorlevel 4  set "Tweak=Disable3RDPartyApps"
	if errorlevel 3  set "Tweak=DisableDriversUpdates"
	if errorlevel 2  set "Tweak=HideTaskViewIcon"
	if errorlevel 1  set "Tweak=DisableCortanaApp"
)

cls
echo.===============================================================================
echo.                           MSMG 工具箱 - 应用调整
echo.===============================================================================
echo.
:: 获取安装映像索引体系结构
if "%ImageIndexNo%" equ "*" call :GetImageArchitecture "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageArchitecture "%InstallWim%", %ImageIndexNo% >nul

echo.-------------------------------------------------------------------------------
echo.####正在开始应用调整###########################################################
echo.-------------------------------------------------------------------------------
echo.
echo.    映像文件名称             ：Install.wim
if "%ImageIndexNo%" equ "*" echo.    映像索引范围             ：1-%ImageCount%
if "%ImageIndexNo%" neq "*" echo.    映像索引                 ：%ImageIndexNo%
echo.    映像体系结构             ：%ImageArchitecture%
echo.    映像版本                 ：%ImageVersion%.%ImageServicePackBuild%.%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" echo.    映像版本                 ：%ImageEdition%
echo.    映像默认语言             ：%ImageDefaultLanguage%
echo.
echo.-------------------------------------------------------------------------------
if "%Tweak%" equ "Disable3RDPartyApps" echo.####正在应用禁用自动下载并安装第三方应用调整###################################
if "%Tweak%" equ "DisableCortanaApp" echo.####正在应用禁用 Cortana 应用调整##############################################
if "%Tweak%" equ "DisableDriversUpdates" echo.####正在应用禁止通过 Windows 更新自动更新驱动调整##############################
if "%Tweak%" equ "DisableReservedStorage" echo.####正在应用禁用 Microsoft 用于进行 Windows 更新保留的存储空间#################
if "%Tweak%" equ "DisableWindowsDefender" echo.####正在应用禁用 Windows Defender 调整#########################################
if "%Tweak%" equ "DisableWindowsUpdate" echo.####正在应用禁用 Windows 更新调整##############################################
if "%Tweak%" equ "DisableWindowsUpgrade" echo.####正在应用禁用自动升级 Windows 操作系统调整##################################
if "%Tweak%" equ "EnableFMP3ProCodec" echo.####正在应用启用 Fraunhofer MP3 Professional Codec 调整#########################
if "%Tweak%" equ "EnableFullResetBase" echo.####正在应用使用完整 ResetBase 启用 DISM 映像清理调整###########################
if "%Tweak%" equ "EnablePhotoViewer" echo.####正在应用启用 Windows 照片查看器调整########################################
if "%Tweak%" equ "ForceLatestNetFramework" echo.####正在应用强制 .NET 程序使用最新的 .NET Framework 调整#######################
if "%Tweak%" equ "HideTaskViewIcon" echo.####正在应用隐藏任务栏任务视图图标调整#########################################
echo.-------------------------------------------------------------------------------
echo.
if "%ImageIndexNo%" equ "*" (
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.
		if not %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]###############################
		if %ImageIndexNo% gtr 9 echo.#########################[Install.wim，索引 ：%%i]##############################
		echo.		
		echo.正在安装映像注册表……
		call :MountImageRegistry "%InstallMount%\%%i"
		echo.正在将注册表设置合并到映像注册表……
		
		call :ApplyTweaks "%Tweak%"

		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
	)
) else (
	echo.正在安装映像注册表……
	call :MountImageRegistry "%InstallMount%"
	echo.正在将注册表设置合并到映像注册表……

	call :ApplyTweaks "%Tweak%"

	echo.正在卸载映像注册表……
	call :UnMountImageRegistry
)
echo.
echo.-------------------------------------------------------------------------------
echo.####应用调整已完成#############################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set Tweaks=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 应用调整模块
:: 输入参数 [ %~1 ：调整名称]
::-------------------------------------------------------------------------------------------
:ApplyTweaks

setlocal

set "Tweak=%~1"

if "%Tweak%" equ "DisableCortanaApp" (
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" /v "HarvestContacts" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "DeviceHistoryEnabled" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "HistoryViewEnabled" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows Search" /v "CortanaConsent" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows Search" /v "CortanaIsReplaceable" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows Search" /v "CortanaIsReplaced" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Policies\Microsoft\InputPersonalization" /v "RestrictImplicitInkCollection" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Policies\Microsoft\InputPersonalization" /v "RestrictImplicitTextCollection" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\ServiceUI" /v "EnableCortana" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\InputPersonalization" /v "RestrictImplicitInkCollection" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\InputPersonalization" /v "RestrictImplicitTextCollection" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" /v "HarvestContacts" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Personalization\Settings" /v "AcceptedPrivacyPolicy" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "DeviceHistoryEnabled" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "HistoryViewEnabled" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows Search" /v "CortanaConsent" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows Search" /v "CortanaIsReplaceable" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows Search" /v "CortanaIsReplaced" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Windows Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\PolicyManager\current\device\AboveLock" /v "AllowCortanaAboveLock" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\PolicyManager\current\device\Experience" /v "AllowCortana" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Speech_OneCore\Preferences" /v "ModelDownloadAllowed" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "AllowCloudSearch" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "AllowCortana" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "AllowCortanaAboveLock" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "AllowSearchToUseLocation" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "ConnectedSearchPrivacy" /t REG_DWORD /d "3" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "ConnectedSearchSafeSearch" /t REG_DWORD /d "3" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "ConnectedSearchUseWeb" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "ConnectedSearchUseWebOverMeteredConnections" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v "DisableWebSearch" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Wow6432Node\Microsoft\Windows\Windows Search" /v "AllowCortana" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Wow6432Node\Microsoft\Windows\Windows Search" /v "AllowCortanaAboveLock" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" /v "Block Cortana ActionUriServer.exe" /t REG_SZ /d "v2.26|Action=Block|Active=TRUE|Dir=Out|RA42=IntErnet|RA62=IntErnet|App=C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy\ActionUriServer.exe|Name=Block Cortana ActionUriServer.exe|Desc=Block Cortana Outbound UDP/TCP Traffic|" /f >nul 2>&1
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" /v "Block Cortana Package" /t REG_SZ /d "v2.26|Action=Block|Active=TRUE|Dir=Out|RA42=IntErnet|RA62=IntErnet|Name=Block Cortana Package|Desc=Block Cortana Outbound UDP/TCP Traffic|AppPkgId=S-1-15-2-1861897761-1695161497-2927542615-642690995-327840285-2659745135-2630312742|Platform=2:6:2|Platform2=GTEQ|" /f >nul 2>&1
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" /v "Block Cortana PlacesServer.exe" /t REG_SZ /d "v2.26|Action=Block|Active=TRUE|Dir=Out|RA42=IntErnet|RA62=IntErnet|App=C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy\PlacesServer.exe|Name=Block Cortana PlacesServer.exe|Desc=Block Cortana Outbound UDP/TCP Traffic|" /f >nul 2>&1
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" /v "Block Cortana RemindersServer.exe" /t REG_SZ /d "v2.26|Action=Block|Active=TRUE|Dir=Out|RA42=IntErnet|RA62=IntErnet|App=C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy\RemindersServer.exe|Name=Block Cortana RemindersServer.exe|Desc=Block Cortana Outbound UDP/TCP Traffic|" /f >nul 2>&1
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" /v "Block Cortana RemindersShareTargetApp.exe" /t REG_SZ /d "v2.26|Action=Block|Active=TRUE|Dir=Out|RA42=IntErnet|RA62=IntErnet|App=C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy\RemindersShareTargetApp.exe|Name=Block Cortana RemindersShareTargetApp.exe|Desc=Block Cortana Outbound UDP/TCP Traffic|" /f >nul 2>&1
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules" /v "Block Cortana SearchUI.exe" /t REG_SZ /d "v2.26|Action=Block|Active=TRUE|Dir=Out|RA42=IntErnet|RA62=IntErnet|App=C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy\SearchUI.exe|Name=Block Cortana SearchUI.exe|Desc=Block Cortana Outbound UDP/TCP Traffic|" /f >nul 2>&1
)
		
if "%Tweak%" equ "HideTaskViewIcon" Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "ShowTaskViewButton" /t REG_DWORD /d "0" /f >nul

if "%Tweak%" equ "DisableDriversUpdates" (
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Device Metadata" /v "PreventDeviceMetadataFromNetwork" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\DriverSearching" /v "DontPromptForWindowsUpdate" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\DriverSearching" /v "DontSearchWindowsUpdate" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\DriverSearching" /v "DriverUpdateWizardWuSearchEnabled" /t REG_DWORD /d "0" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\DriverSearching" /v "SearchOrderConfig" /t REG_DWORD /d "1" /f >nul		
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "ExcludeWUDriversInQualityUpdate" /t REG_DWORD /d "1" /f >nul
)

if "%Tweak%" equ "Disable3RDPartyApps" (
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "OemPreInstalledAppsEnabled" /t REG_DWORD /d "0" /f >nul
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEnabled" /t REG_DWORD /d "0" /f >nul
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SilentInstalledAppsEnabled" /t REG_DWORD /d "0" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v "DisableWindowsConsumerFeatures" /t REG_DWORD /d "1" /f >nul
)

if "%Tweak%" equ "DisableWindowsDefender" (
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\Windows Security Health\State" /v "AccountProtection_MicrosoftAccount_Disconnected" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows Security Health\State" /v "AccountProtection_MicrosoftAccount_Disconnected" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows Defender\Features" /v "TamperProtection" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\MRT" /v "DontOfferThroughWUAU" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\MRT" /v "DontReportInfectionInformation" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows Defender" /v "DisableAntiSpyware" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" /v "SpyNetReporting" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" /v "SubmitSamplesConsent" /t REG_DWORD /d "2" /f >nul 2>&1
)
	
if "%Tweak%" equ "DisableWindowsUpgrade" (
	if "%SelectedSourceOS%" neq "w10" (
		Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\Gwx" /v "DisableGwx" /t REG_DWORD /d "1" /f >nul
		Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "DisableOSUpgrade" /t REG_DWORD /d "1" /f >nul
	)
			
	if "%SelectedSourceOS%" equ "w10" (
		Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "DeferUpdatePeriod" /t REG_DWORD /d "0" /f >nul 2>&1
		Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "DeferUpgrade" /t REG_DWORD /d "1" /f >nul 2>&1
		Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "DeferUpgradePeriod" /t REG_DWORD /d "1" /f >nul 2>&1
		Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "AUOptions" /t REG_DWORD /d "2" /f >nul
	)
)

if "%Tweak%" equ "DisableWindowsUpdate" (
	Reg add "HKLM\TK_DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-310093Enabled" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-310093Enabled" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_NTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" /v "SystemSettingsDownloadMode" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Speech_OneCore\Preferences" /v "ModelDownloadAllowed" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" /v "OptInOOBE" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" /v "DODownloadMode" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /v "AutoDownload" /t REG_DWORD /d "2" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\7971f918-a847-4430-9279-4a52d1efe18d" /v "registeredWithAU" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "HideMCTLink" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Speech" /v "AllowSpeechModelUpdate" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" /v "DODownloadMode" /t REG_DWORD /d "0" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" /v "DODownloadMode" /t REG_DWORD /d "63" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "AUOptions" /t REG_DWORD /d "2" /f >nul 2>&1
	Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" /t REG_DWORD /d "1" /f >nul 2>&1
	Reg add "HKLM\TK_SYSTEM\ControlSet001\Services\wuauserv" /v "Start" /t REG_DWORD /d "4" /f >nul 2>&1
)
		
if "%Tweak%" equ "DisableReservedStorage" Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" /v "ShippedWithReserves" /t REG_DWORD /d "0" /f >nul
if "%Tweak%" equ "ForceLatestNetFramework" Reg add "HKLM\TK_SOFTWARE\Microsoft\.NETFramework" /v "OnlyUseLatestCLR" /t REG_DWORD /d "1" /f >nul

if "%Tweak%" equ "EnablePhotoViewer" (
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "emffile_.emf" /t REG_DWORD /d "0" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "rlefile_.rle" /t REG_DWORD /d "0" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "wmffile_.wmf" /t REG_DWORD /d "0" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer" /v "GlobalAssocChangedCounter" /t REG_DWORD /d "13" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\UserChoice" /v "Hash" /t REG_SZ /d "TDU75KWAGi4=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Bitmap" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.dib\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.dib\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.dib\UserChoice" /v "Hash" /t REG_SZ /d "hAQpLYJfRYE=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.dib\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Bitmap" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.gif\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.gif\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.gif\UserChoice" /v "Hash" /t REG_SZ /d "1in4hcmDrB4=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.gif\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Gif" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jfif\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jfif\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jfif\UserChoice" /v "Hash" /t REG_SZ /d "Y5upkzp3g5E=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jfif\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.JFIF" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpe\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpe\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpe\UserChoice" /v "Hash" /t REG_SZ /d "ZIeqfdrNtFk=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpe\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpeg\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpeg\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpeg\UserChoice" /v "Hash" /t REG_SZ /d "iVWM3EAePKw=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpeg\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\UserChoice" /v "Hash" /t REG_SZ /d "Xq9gH4jXoFM=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jxr\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jxr\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jxr\UserChoice" /v "Hash" /t REG_SZ /d "ahz7f/Yl09M=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jxr\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Wdp" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\UserChoice" /v "Hash" /t REG_SZ /d "Evm7jp++AWA=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Png" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\UserChoice" /v "Hash" /t REG_SZ /d "wEj9gLqtYH4=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\UserChoice" /v "ProgId" /t REG_SZ /d "TIFImage.Document" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tiff\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tiff\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tiff\UserChoice" /v "Hash" /t REG_SZ /d "/r2V12Yryig=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tiff\UserChoice" /v "ProgId" /t REG_SZ /d "TIFImage.Document" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wdp\OpenWithList" /v "a" /t REG_SZ /d "PhotoViewer.dll" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wdp\OpenWithList" /v "MRUList" /t REG_SZ /d "a" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wdp\UserChoice" /v "Hash" /t REG_SZ /d "/qcrPB0bhuI=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wdp\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Wdp" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.bmp\UserChoice" /v "Hash" /t REG_SZ /d "rEigxhAPyos=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.bmp\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Bitmap" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.dib\UserChoice" /v "Hash" /t REG_SZ /d "R60f5QZs3Hg=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.dib\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Bitmap" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.gif\UserChoice" /v "Hash" /t REG_SZ /d "YcQO9pssSPU=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.gif\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Gif" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jfif\UserChoice" /v "Hash" /t REG_SZ /d "5yjvWKb+Jns=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jfif\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.JFIF" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jpe\UserChoice" /v "Hash" /t REG_SZ /d "TujD2rCi+po=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jpe\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jpeg\UserChoice" /v "Hash" /t REG_SZ /d "wdZ9wQI4vW8=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jpeg\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jpg\UserChoice" /v "Hash" /t REG_SZ /d "3xY0V0JOiFc=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jpg\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jxr\UserChoice" /v "Hash" /t REG_SZ /d "ENXEd5Uzg84=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.jxr\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Wdp" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.png\UserChoice" /v "Hash" /t REG_SZ /d "SPesrUKrIFE=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.png\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Png" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.tif\UserChoice" /v "Hash" /t REG_SZ /d "bCXQRSAHD/I=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.tif\UserChoice" /v "ProgId" /t REG_SZ /d "TIFImage.Document" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.tiff\UserChoice" /v "Hash" /t REG_SZ /d "7F/LfjhVnes=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.tiff\UserChoice" /v "ProgId" /t REG_SZ /d "TIFImage.Document" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.wdp\UserChoice" /v "Hash" /t REG_SZ /d "tu0JqOen+Es=" /f >nul
	Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.wdp\UserChoice" /v "ProgId" /t REG_SZ /d "PhotoViewer.FileAssoc.Wdp" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\Applications\photoviewer.dll\shell\open" /v "MuiVerb" /t REG_SZ /d "@photoviewer.dll,-3043" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\Applications\photoviewer.dll\shell\open\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\Applications\photoviewer.dll\shell\open\DropTarget" /v "Clsid" /t REG_SZ /d "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\Applications\photoviewer.dll\shell\print\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\Applications\photoviewer.dll\shell\print\DropTarget" /v "Clsid" /t REG_SZ /d "{60fd46de-f830-4894-a628-6fa81bc0190d}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Bitmap" /v "FriendlyTypeName" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll,-3056" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Bitmap" /v "ImageOptionFlags" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Bitmap\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\imageres.dll,-70" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Bitmap\shell\open\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Bitmap\shell\open\DropTarget" /v "Clsid" /t REG_SZ /d "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Gif" /v "FriendlyTypeName" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll,-3057" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Gif" /v "ImageOptionFlags" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Gif\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\imageres.dll,-83" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Gif\shell\open\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Gif\shell\open\DropTarget" /v "Clsid" /t REG_SZ /d "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF" /v "EditFlags" /t REG_DWORD /d "65536" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF" /v "FriendlyTypeName" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll,-3055" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF" /v "ImageOptionFlags" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\imageres.dll,-72" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\shell\open" /v "MuiVerb" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\photoviewer.dll,-3043" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\shell\open\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\shell\open\DropTarget" /v "Clsid" /t REG_SZ /d "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Jpeg" /v "EditFlags" /t REG_DWORD /d "65536" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Jpeg" /v "FriendlyTypeName" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll,-3055" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Jpeg" /v "ImageOptionFlags" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Jpeg\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\imageres.dll,-72" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Jpeg\shell\open" /v "MuiVerb" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\photoviewer.dll,-3043" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Jpeg\shell\open\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Jpeg\shell\open\DropTarget" /v "Clsid" /t REG_SZ /d "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Png" /v "FriendlyTypeName" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll,-3057" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Png" /v "ImageOptionFlags" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Png\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\imageres.dll,-71" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Png\shell\open\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Png\shell\open\DropTarget" /v "Clsid" /t REG_SZ /d "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Tiff" /v "FriendlyTypeName" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll,-3058" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Tiff" /v "ImageOptionFlags" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Tiff\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\imageres.dll,-122" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Tiff\shell\open" /v "MuiVerb" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\photoviewer.dll,-3043" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Tiff\shell\open\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Tiff\shell\open\DropTarget" /v "Clsid" /t REG_SZ /d "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Wdp" /v "EditFlags" /t REG_DWORD /d "65536" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Wdp" /v "ImageOptionFlags" /t REG_DWORD /d "1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Wdp\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\wmphoto.dll,-400" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Wdp\shell\open" /v "MuiVerb" /t REG_EXPAND_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\photoviewer.dll,-3043" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Wdp\shell\open\command" /ve /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\rundll32.exe \"%%ProgramFiles%%\Windows 照片查看器\PhotoViewer.dll\", ImageView_Fullscreen %%1" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Classes\PhotoViewer.FileAssoc.Wdp\shell\open\DropTarget" /v "Clsid" /t REG_SZ /d "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities" /v "ApplicationDescription" /t REG_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\photoviewer.dll,-3069" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities" /v "ApplicationName" /t REG_SZ /d "@%%ProgramFiles%%\Windows 照片查看器\photoviewer.dll,-3009" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".bmp" /t REG_SZ /d "PhotoViewer.FileAssoc.Bitmap" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".dib" /t REG_SZ /d "PhotoViewer.FileAssoc.Bitmap" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".gif" /t REG_SZ /d "PhotoViewer.FileAssoc.Gif" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".jfif" /t REG_SZ /d "PhotoViewer.FileAssoc.JFIF" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".jpe" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".jpeg" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".jpg" /t REG_SZ /d "PhotoViewer.FileAssoc.Jpeg" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".jxr" /t REG_SZ /d "PhotoViewer.FileAssoc.Wdp" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".png" /t REG_SZ /d "PhotoViewer.FileAssoc.Png" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".tif" /t REG_SZ /d "PhotoViewer.FileAssoc.Tiff" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".tiff" /t REG_SZ /d "PhotoViewer.FileAssoc.Tiff" /f >nul
	Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows 照片查看器\Capabilities\FileAssociations" /v ".wdp" /t REG_SZ /d "PhotoViewer.FileAssoc.Wdp" /f >nul
)

if "%Tweak%" equ "EnableFMP3ProCodec" (
	if "%ImageArchitecture%" equ "x86" (
		Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc" /v "%%SystemRoot%%\System32\l3codecp.acm" /t REG_SZ /d "Fraunhofer IIS MPEG Layer-3 Codec (Professional)" /f >nul
		Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32" /v "msacm.l3acm" /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\l3codecp.acm" /f >nul
		Reg delete "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc" /f >nul 2>&1
	)

	if "%ImageArchitecture%" equ "x64" (
		Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc" /v "%%SystemRoot%%\System32\l3codecp.acm" /t REG_SZ /d "Fraunhofer IIS MPEG Layer-3 Codec (Professional)" /f >nul
		Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32" /v "msacm.l3acm" /t REG_EXPAND_SZ /d "%%SystemRoot%%\System32\l3codecp.acm" /f >nul
		Reg add "HKLM\TK_SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc" /v "%%SystemRoot%%\SysWOW64\l3codecp.acm" /t REG_SZ /d "Fraunhofer IIS MPEG Layer-3 Codec (Professional)" /f >nul
		Reg add "HKLM\TK_SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Drivers32" /v "msacm.l3acm" /t REG_EXPAND_SZ /d "%%SystemRoot%%\SysWOW64\l3codecp.acm" /f >nul
		Reg delete "HKLM\TK_SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc" /f >nul 2>&1
		Reg delete "HKLM\TK_SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\drivers.desc" /f >nul 2>&1
	)
)

if "%Tweak%" equ "EnableFullResetBase" Reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Configuration" /v "DisableResetbase" /t REG_DWORD /d "0" /f >nul

set Tweak=

endlocal

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 清理源映像模块
::-------------------------------------------------------------------------------------------
:CleanupSource

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 使用组件清理和 ResetBase 清理源映像
echo.===============================================================================
echo.
:: 卸载映像注册表（如果已安装）
call :UnMountImageRegistry
echo.-------------------------------------------------------------------------------
echo.####正在开始使用组件清理和 ResetBase 清理源映像################################
echo.-------------------------------------------------------------------------------
echo.
if "%IsBootImageSelected%" equ "Yes" (
	:: 使用 ResetBase 选项执行对 [Boot.wim，索引 ：1 和 2] 的映像组件清理
	for /l %%j in (1, 1, 2) do (
		echo.-------------------------------------------------------------------------------
		echo.正在执行对 [Boot.wim，索引 ：%%j] 的映像组件清理……
		echo.-------------------------------------------------------------------------------
		call :CleanupImage "%BootMount%\%%j", "ComponentCleanupResetBase"
	)
)

if "%IsRecoveryImageSelected%" equ "Yes" (
	:: 使用 ResetBase 选项执行对 [WinRE.wim] 的映像组件清理
	echo.-------------------------------------------------------------------------------
	echo.正在执行对 [WinRe.wim，索引 ：1] 的映像组件清理……
	echo.-------------------------------------------------------------------------------
	call :CleanupImage "%WinReMount%", "ComponentCleanupResetBase"	
) 

:: 使用 ResetBase 选项执行对 [Install.wim] 的映像组件清理
if "%ImageIndexNo%" equ "*" (
	for /L %%k in (1, 1, %ImageCount%) do (
		if exist "%InstallMount%\%%k\Windows\WinSxS\pending.xml" (
			echo.-------------------------------------------------------------------------------
			echo.正在执行对 [Install.wim，索引 ：%%k] 的映像组件清理……
			echo.-------------------------------------------------------------------------------
			echo.
			echo.当 Pending.xml 存在时无法执行映像组件清理……
			echo.
		)
		if not exist "%InstallMount%\%%k\Windows\WinSxS\pending.xml" (
			echo.-------------------------------------------------------------------------------
			echo.正在执行对 [Install.wim，索引 ：%%k] 的映像组件清理……
			echo.-------------------------------------------------------------------------------
			call :CleanupImage "%InstallMount%\%%k", "ComponentCleanupResetBase"
		)
	)
) else (
	if exist "%InstallMount%\Windows\WinSxS\pending.xml" (
		echo.-------------------------------------------------------------------------------
		echo.正在执行对 [Install.wim，索引 ：%ImageIndexNo%] 的映像组件清理……
		echo.-------------------------------------------------------------------------------
		echo.
		echo.当 Pending.xml 存在时无法执行映像组件清理……
		echo.
	)
	if not exist "%InstallMount%\Windows\WinSxS\pending.xml" (
		echo.-------------------------------------------------------------------------------
		echo.正在执行对 [Install.wim，索引 ：%ImageIndexNo%] 的映像组件清理……
		echo.-------------------------------------------------------------------------------
		call :CleanupImage "%InstallMount%", "ComponentCleanupResetBase"
	)
)
echo.-------------------------------------------------------------------------------
echo.####使用组件清理和 ResetBase 清理源映像已完成##################################
echo.-------------------------------------------------------------------------------
echo.

:Stop
echo.===============================================================================
echo.
pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 应用并保存更改到到源映像模块
::-------------------------------------------------------------------------------------------
:SaveSource

cls
echo.===============================================================================
echo.                    MSMG 工具箱 - 应用并保存更改到源映像
echo.===============================================================================
echo.
:: 卸载映像注册表（如果已安装）
call :UnMountImageRegistry
echo.-------------------------------------------------------------------------------
echo.####正在开始应用并保存更改到源映像#############################################
echo.-------------------------------------------------------------------------------
echo.
choice /C:YN /N /M "你是否要清理 Image Windows 文件夹 ？ [是‘Y’/否‘N’] ："
if "%errorlevel%" equ "1" (
	echo.
	echo.正在清理 Image Windows 文件夹……
	:: 执行对 [Boot.wim，索引 ：1 和 2] 映像 Windows 文件夹清理
	if "%IsBootImageSelected%" equ "Yes" (
		for /l %%j in (1, 1, 2) do (
			if exist "%BootMount%\%%j\Windows\WinSxS\Backup\*.*" del /f /q "%InstallMount%\Windows\WinSxS\Backup\*.*" >nul 2>&1
			if exist "%BootMount%\%%j\Windows\WinSxS\ManifestCache\*.bin" del /f /q "%BootMount%\%%j\Windows\WinSxS\ManifestCache\*.bin" >nul 2>&1
			if exist "%BootMount%\%%j\Windows\WinSxS\Temp\PendingDeletes\*" del /f /q "%BootMount%\%%j\Windows\WinSxS\Temp\PendingDeletes\*" >nul 2>&1
			if exist "%BootMount%\%%j\Windows\WinSxS\Temp\TransformerRollbackData\*" del /s /f /q "%BootMount%\%%j\Windows\WinSxS\Temp\TransformerRollbackData\*" >nul 2>&1
			if exist "%BootMount%\%%j\Windows\inf\*.log" del /f /q "%BootMount%\%%j\Windows\inf\*.log" >nul 2>&1
			if exist "%BootMount%\%%j\Windows\CbsTemp\*" (
				for /f %%i in ('"dir /s /b /ad "%BootMount%\%%j\Windows\CbsTemp\*"" 2^>nul') do (rd /q /s %%i >nul 2>&1)
				del /s /f /q "%BootMount%\%%j\Windows\CbsTemp\*" >nul 2>&1
			)
		)
	)

	:: 执行对 [WinRE.wim，索引 ：1] 映像 Windows 文件夹清理
	if "%IsRecoveryImageSelected%" equ "Yes" (
		if exist "%WinReMount%\Windows\WinSxS\Backup\*.*" del /f /q "%InstallMount%\Windows\WinSxS\Backup\*.*" >nul 2>&1
		if exist "%WinReMount%\Windows\WinSxS\ManifestCache\*.bin" del /f /q "%WinReMount%\Windows\WinSxS\ManifestCache\*.bin" >nul 2>&1
		if exist "%WinReMount%\Windows\WinSxS\Temp\PendingDeletes\*" del /f /q "%WinReMount%\Windows\WinSxS\Temp\PendingDeletes\*" >nul 2>&1
		if exist "%WinReMount%\Windows\WinSxS\Temp\TransformerRollbackData\*" del /s /f /q "%WinReMount%\Windows\WinSxS\Temp\TransformerRollbackData\*" >nul 2>&1
		if exist "%WinReMount%\Windows\inf\*.log" del /f /q "%WinReMount%\Windows\inf\*.log" >nul 2>&1
		if exist "%WinReMount%\Windows\CbsTemp\*" (
			for /f %%i in ('"dir /s /b /ad "%WinReMount%\Windows\CbsTemp\*"" 2^>nul') do (rd /q /s %%i >nul 2>&1)
			del /s /f /q "%WinReMount%\Windows\CbsTemp\*" >nul 2>&1
		)
	) 

	:: 执行对 [Install.wim] 映像 Windows 文件夹清理
	if "%ImageIndexNo%" equ "*" (
		for /L %%k in (1, 1, %ImageCount%) do (
			if exist "%InstallMount%\%%k\$Recycle.Bin" rd /q /s "%InstallMount%\%%k\$Recycle.Bin" >nul 2>&1
			if exist "%InstallMount%\%%k\PerfLogs" rd /q /s "%InstallMount%\%%k\PerfLogs" >nul 2>&1
			if exist "%InstallMount%\%%k\Windows\WinSxS\Backup\*.*" del /f /q "%InstallMount%\%%k\Windows\WinSxS\Backup\*.*" >nul 2>&1
			if exist "%InstallMount%\%%k\Windows\WinSxS\ManifestCache\*.bin" del /f /q "%InstallMount%\%%k\Windows\WinSxS\ManifestCache\*.bin" >nul 2>&1
			if exist "%InstallMount%\%%k\Windows\WinSxS\Temp\PendingDeletes\*" del /f /q "%InstallMount%\%%k\Windows\WinSxS\Temp\PendingDeletes\*" >nul 2>&1
			if exist "%InstallMount%\%%k\Windows\WinSxS\Temp\TransformerRollbackData\*" del /f /q "%InstallMount%\%%k\Windows\WinSxS\Temp\TransformerRollbackData\*" >nul 2>&1
			if exist "%InstallMount%\%%k\Windows\inf\*.log" del /f /q "%InstallMount%\%%k\Windows\inf\*.log" >nul 2>&1		
			if exist "%InstallMount%\%%k\Windows\CbsTemp\*" (
				for /f %%i in ('"dir /s /b /ad "%InstallMount%\%%k\Windows\CbsTemp\*"" 2^>nul') do (rd /q /s %%i >nul 2>&1)
				del /s /f /q "%InstallMount%\%%k\Windows\CbsTemp\*" >nul 2>&1
			)
		)
	) else (
		if exist "%InstallMount%\$Recycle.Bin" rd /q /s "%InstallMount%\$Recycle.Bin" >nul 2>&1
		if exist "%InstallMount%\PerfLogs" rd /q /s "%InstallMount%\PerfLogs" >nul 2>&1
		if exist "%InstallMount%\Windows\WinSxS\Backup\*.*" del /f /q "%InstallMount%\Windows\WinSxS\Backup\*.*" >nul 2>&1
		if exist "%InstallMount%\Windows\WinSxS\ManifestCache\*.bin" del /f /q "%InstallMount%\Windows\WinSxS\ManifestCache\*.bin" >nul 2>&1
		if exist "%InstallMount%\Windows\WinSxS\Temp\PendingDeletes\*" del /f /q "%InstallMount%\Windows\WinSxS\Temp\PendingDeletes\*" >nul 2>&1
		if exist "%InstallMount%\Windows\WinSxS\Temp\TransformerRollbackData\*" del /f /q "%InstallMount%\Windows\WinSxS\Temp\TransformerRollbackData\*" >nul 2>&1
		if exist "%InstallMount%\Windows\inf\*.log" del /f /q "%InstallMount%\Windows\inf\*.log" >nul 2>&1
		if exist "%InstallMount%\Windows\CbsTemp\*" (
			for /f %%i in ('"dir /s /b /ad "%InstallMount%\Windows\CbsTemp\*"" 2^>nul') do (rd /q /s %%i >nul 2>&1)
			del /s /f /q "%InstallMount%\Windows\CbsTemp\*" >nul 2>&1
		)	
	)
)

echo.

:: 保存并卸载源启动映像
if "%IsBootImageSelected%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	echo.正在应用更改并卸载源 [Boot.wim，索引 ：1] 映像……
	echo.-------------------------------------------------------------------------------
	call :UnMountImage "%BootMount%\1", "Commit"
	echo.-------------------------------------------------------------------------------
	echo.正在应用更改并卸载源 [Boot.wim，索引 ：2] 映像……
	echo.-------------------------------------------------------------------------------
	call :UnMountImage "%BootMount%\2", "Commit"
)

:: 保存并卸载源安装和恢复映像
if "%ImageIndexNo%" equ "*" (
	if "%IsRecoveryImageSelected%" equ "Yes" (
		echo.-------------------------------------------------------------------------------
		echo.正在应用更改并卸载源 [Install.wim，索引 ：%%i] 映像……
		echo.-------------------------------------------------------------------------------
		call :UnMountImage "%WinReMount%", "Commit"

		:: 使用最大压缩重建源恢复映像。
		echo.-------------------------------------------------------------------------------
		echo.正在使用最大压缩重建源 [WinRE.wim] 映像……
		echo.-------------------------------------------------------------------------------
		call :ExportImage "%InstallMount%\1\%WinReWim%", "%Temp%\rebuild.wim", "WIM", "No"
		move /y "%Temp%\rebuild.wim" "%InstallMount%\1\%WinReWim%" >nul
		echo.-------------------------------------------------------------------------------
		echo.正在复制源 Windows 恢复映像到源安装映像……
		echo.-------------------------------------------------------------------------------
		echo.
		for /L %%i in (2, 1, %ImageCount%) do (
			echo.正在复制源 [WinRe.wim] 映像到源 [Install.wim，索引 ：%%i] 映像……
			%XCopy% "%InstallMount%\1\%WinReWim%" "%InstallMount%\%%i\%WinReWim%" >nul
		)
		echo.
		echo.-------------------------------------------------------------------------------
	)
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.-------------------------------------------------------------------------------
		echo.正在应用更改并卸载源 [Install.wim，索引 ：%%i] 映像……
		echo.-------------------------------------------------------------------------------
		call:UnMountImage "%InstallMount%\%%i", "Commit"
			call :RemoveFolder "%InstallMount%\%%i"
	)
) else (
	if "%IsRecoveryImageSelected%" equ "Yes" if exist "%InstallMount%\%WinReWim%" (
		echo.-------------------------------------------------------------------------------
		echo.正在应用更改并卸载源 [Install.wim，索引 ：%%i] 映像……
		echo.-------------------------------------------------------------------------------
		call :UnMountImage "%WinReMount%", "Commit"

		:: 使用最大压缩重建源恢复映像。
		echo.-------------------------------------------------------------------------------
		echo.正在使用最大压缩重建源 [WinRE.wim] 映像……
		echo.-------------------------------------------------------------------------------
		call :ExportImage "%InstallMount%\%WinReWim%", "%Temp%\rebuild.wim", "WIM", "No"
		move /y "%Temp%\rebuild.wim" "%InstallMount%\%WinReWim%" >nul		
	)
	echo.-------------------------------------------------------------------------------
	echo.正在应用更改并卸载源 [Install.wim，索引 ：%ImageIndexNo%] 映像……
	echo.-------------------------------------------------------------------------------
	call :UnMountImage "%InstallMount%", "Commit"
)
echo.-------------------------------------------------------------------------------
echo.####应用并保存更改到源映像已完成###############################################
echo.-------------------------------------------------------------------------------
echo.
set IsSourceSelected=No
set IsBootImageSelected=No
set IsRecoveryImageSelected=No
set SelectedSourceOS=

:Stop
echo.===============================================================================
echo.
pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 丢弃更改并卸载源映像模块
::-------------------------------------------------------------------------------------------
:DiscardSource

cls
echo.===============================================================================
echo.                     MSMG 工具箱 - 丢弃更改并卸载源映像
echo.===============================================================================
echo.
:: 卸载映像注册表（如果已安装）
call :UnMountImageRegistry
echo.-------------------------------------------------------------------------------
echo.####正在开始丢弃更改并卸载源映像###############################################
echo.-------------------------------------------------------------------------------
echo.
:: 丢弃并卸载源启动映像
if "%IsBootImageSelected%" equ "Yes" (
	echo.-------------------------------------------------------------------------------
	echo.正在卸载源 [Boot.wim，索引 ：1] 映像……
	echo.-------------------------------------------------------------------------------
	call :UnMountImage "%BootMount%\1", "Discard"
	echo.-------------------------------------------------------------------------------
	echo.正在卸载源 [Boot.wim，索引 ：2] 映像……
	echo.-------------------------------------------------------------------------------
	call :UnMountImage "%BootMount%\2", "Discard"
)

:: 丢弃并卸载源安装和恢复映像
if "%ImageIndexNo%" equ "*" (
	if "%IsRecoveryImageSelected%" equ "Yes" (
		echo.-------------------------------------------------------------------------------
		echo.正在卸载源 [WinRE.wim，索引 ：1] 映像……
		echo.-------------------------------------------------------------------------------
		call :UnMountImage "%WinReMount%", "Discard"
	)
	for /L %%i in (1, 1, %ImageCount%) do (
		echo.-------------------------------------------------------------------------------
		echo.正在卸载源 [Install.wim，索引 ：%%i] 映像……
		echo.-------------------------------------------------------------------------------
		call :UnMountImage "%InstallMount%\%%i", "Discard"
			call :RemoveFolder "%InstallMount%\%%i"
	)
) else (
	if "%IsRecoveryImageSelected%" equ "Yes" if exist "%InstallMount%\%WinReWim%" (
		echo.-------------------------------------------------------------------------------
		echo.正在卸载源 [WinRE.wim，索引 ：1] 映像……
		echo.-------------------------------------------------------------------------------
		call :UnMountImage "%WinReMount%", "Discard"		
	)
	echo.-------------------------------------------------------------------------------
	echo.正在卸载源 [Install.wim，索引 ：%ImageIndexNo%] 映像……
	echo.-------------------------------------------------------------------------------
	call :UnMountImage "%InstallMount%", "Discard"
)
echo.-------------------------------------------------------------------------------
echo.####丢弃更改并卸载源映像已完成#################################################
echo.-------------------------------------------------------------------------------
echo.
set IsSourceSelected=No
set IsBootImageSelected=No
set IsRecoveryImageSelected=No
set SelectedSourceOS=

:Stop
echo.===============================================================================
echo.
pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 重建源映像模块
::-------------------------------------------------------------------------------------------
:RebuildSource

cls
echo.===============================================================================
echo. 	                       MSMG 工具箱 - 重建源映像
echo.===============================================================================
echo.
:: 检查 Windows 源启动映像是否存在
if not exist "%BootWim%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Boot.wim”映像……
	echo.
	echo.请将 Windows 安装程序中的“Boot.wim”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源安装映像是否存在
if not exist "%InstallWim%" (
	echo.在 ^<DVD\Sources^> 文件夹中无法找到 Windows 安装程序“Install.wim”映像……
	echo.
	echo.请将 Windows 安装程序中的“Install.wim”映像复制到 ^<DVD\Sources^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始重建源映像#########################################################
echo.-------------------------------------------------------------------------------
echo.
:: 使用最大压缩比重建源启动映像。
echo.-------------------------------------------------------------------------------
echo.正在使用最大压缩比重建源 [Boot.wim] 映像……
echo.-------------------------------------------------------------------------------
call :ExportImage "%BootWim%", "%Temp%\rebuild.wim", "WIM", "No"
move /y "%Temp%\rebuild.wim" "%BootWim%" >nul

:: 使用最大压缩比重建源安装映像。
echo.-------------------------------------------------------------------------------
echo.正在使用最大压缩比重建源 [Install.wim] 映像……
echo.-------------------------------------------------------------------------------
call :ExportImage "%InstallWim%", "%Temp%\rebuild.wim", "WIM", "No"
move /y "%Temp%\rebuild.wim" "%InstallWim%" >nul
echo.-------------------------------------------------------------------------------
echo.####重建源映像已完成###########################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 制作用于刻录 DVD 光盘的 DVD ISO 镜像模块
::-------------------------------------------------------------------------------------------
:MakeISO

setlocal

set "BIOSBoot=%DVD%\boot\etfsboot.com"
set "UEFIBoot=%DVD%\efi\microsoft\boot\efisys.bin"
set ISOLabel=
set ISOFileName=

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 制作 DVD ISO 镜像
echo.===============================================================================
echo.

:: 检查源文件是否被应用
if "%IsSourceSelected%" equ "Yes" (
	echo.当源操作系统被选择时，无法使用此功能……
	goto :Stop
)

:: 检查 Windows 源 DVD 文件夹是否是空的
if not exist "%BIOSBoot%" (
	echo.Windows 安装源文件夹 ^<DVD^> 是空的……
	echo.
	echo.请复制安装源文件到 ^<DVD^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源 DVD 文件夹是否是空的
if not exist "%BootWim%" (
	echo.Windows 安装源文件夹 ^<DVD^> 是空的……
	echo.
	echo.请复制安装源文件到 ^<DVD^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源 DVD 文件夹是否是空的
if not exist "%InstallWim%" if not exist "%InstallEsd%" if not exist "%DVD%\sources\*.swm" (
	echo.Windows 安装源文件夹 ^<DVD^> 是空的……
	echo.
	echo.请复制安装源文件到 ^<DVD^> 文件夹……
	goto :Stop
)

call :CreateFolder "%ISO%"

echo.-------------------------------------------------------------------------------
echo.####正在开始建立 DVD ISO 镜像##################################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 DVD ISO 镜像详细信息##############################################
echo.-------------------------------------------------------------------------------
echo.
:: 获取 ISO 卷标名称
set /p ISOLabel=请输入 ISO 卷标 ：
echo.

:: 获取 ISO 文件名称
set /p ISOFileName=请输入 ISO 文件名称 ：
echo.

:: 建立用于使用 BIOS/UEFI 引导的系统的 DVD ISO 镜像。
echo.-------------------------------------------------------------------------------
echo.####正在建立 DVD ISO 映像######################################################
echo.-------------------------------------------------------------------------------
if "%ISOLabel%" equ "" (
	if exist "%UEFIBoot%" "%Oscdimg%" -bootdata:2#p0,e,b"%BIOSBoot%"#pEF,e,b"%UEFIBoot%" -o -h -m -u2 -udfver102 "%DVD%" "%ISO%\%ISOFileName%.iso"
	if not exist "%UEFIBoot%" "%Oscdimg%" -bootdata:1#p0,e,b"%BIOSBoot%" -o -h -m -u2 -udfver102 "%DVD%" "%ISO%\%ISOFileName%.iso"
)

if "%ISOLabel%" neq "" (
	if exist "%UEFIBoot%" "%Oscdimg%" -bootdata:2#p0,e,b"%BIOSBoot%"#pEF,e,b"%UEFIBoot%" -o -h -m -u2 -udfver102 -l"%ISOLabel%" "%DVD%" "%ISO%\%ISOFileName%.iso"
	if not exist "%UEFIBoot%" "%Oscdimg%" -bootdata:1#p0,e,b"%BIOSBoot%" -o -h -m -u2 -udfver102 -l"%ISOLabel%" "%DVD%" "%ISO%\%ISOFileName%.iso"
)
echo.
echo.-------------------------------------------------------------------------------
echo.####建立 DVD ISO 映像已完成####################################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set BIOSBoot=
set UEFIBoot=
set ISOLabel=
set ISOFileName=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 刻录 DVD ISO 镜像到 DVD 光盘模块
::-------------------------------------------------------------------------------------------
:BurnISO

setlocal

set DvdDrive=
set ISOFileName=

cls
echo.===============================================================================
echo.                 MSMG 工具箱 - 刻录 DVD ISO 镜像到 DVD 光盘
echo.===============================================================================
echo.

:: 检查 ISO 文件夹是否是空的
if not exist "%ISO%\*.iso" (
	echo.ISO 镜像文件夹 ^<ISO^> 是空的……
	echo.
	echo.请复制 ISO 镜像到 ^<ISO^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始刻录 DVD ISO 镜像到 DVD 光盘#######################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 DVD 驱动器和 DVD ISO 镜像详细信息#################################
echo.-------------------------------------------------------------------------------
echo.
:: 获取 ISO 文件名称
set /p ISOFileName=请输入 ISO 文件名称 ：
echo.
:: 获取 DVD 驱动器盘符
set /p DvdDrive=请输入 DVD 盘符 ：
echo.
echo.-------------------------------------------------------------------------------
echo.####正在刻录 DVD ISO 镜像到 DVD 光盘###########################################
echo.-------------------------------------------------------------------------------
echo.
echo.正在刻录 ISO 镜像文件 [%ISOFileName%.iso] 到 DVD 驱动器 [%DvdDrive%:]……
echo.
%DvdBurn% "%DvdDrive%:" "%ISO%\%ISOFileName%.iso"
echo.
echo.-------------------------------------------------------------------------------
echo.####刻录 DVD ISO 镜像到 DVD 光盘已完成#########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set DvdDrive=
set ISOFileName=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 复制源文件夹到 USB 闪存驱动器模块
::-------------------------------------------------------------------------------------------
:CopyUSB

setlocal

set USBDriveLetter=
set USBDriveLabel=

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 复制源文件夹到 USB 闪存驱动器
echo.===============================================================================
echo.

:: 检查源文件是否被应用
if "%IsSourceSelected%" equ "Yes" (
	echo.当源操作系统被选择时，无法使用此功能……
	goto :Stop
)

:: 检查 Windows 源 DVD 文件夹是否是空的
if not exist "%BootWim%" (
	echo.Windows 安装源文件夹 ^<DVD^> 是空的……
	echo.
	echo.请复制安装源文件到 ^<DVD^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源 DVD 文件夹是否是空的
if not exist "%InstallWim%" if not exist "%InstallEsd%" (
	echo.Windows 安装源文件夹 ^<DVD^> 是空的……
	echo.
	echo.请复制安装源文件到 ^<DVD^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始复制源文件夹到 USB 闪存驱动器######################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 USB 闪存驱动器选项################################################
echo.-------------------------------------------------------------------------------
echo.
:: 显示可用的 USB 闪存驱动器。
echo.正在列出可用的 USB 闪存驱动器……
call :ListDisks

:: 获取 USB 闪存驱动器盘符
set /p USBDriveLetter=请输入 USB 闪存驱动器盘符 ：
 
:: 设置 USB 闪存驱动器盘符
set "USBDriveLetter=%USBDriveLetter%:"
echo.
echo.-------------------------------------------------------------------------------
echo.####正在复制源文件夹到 USB 闪存驱动器##########################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在复制源文件和文件夹，请稍候……
echo.-------------------------------------------------------------------------------
echo.
echo.源驱动器     ： "%DVD%"		
echo.目标驱动器   ： %USBDriveLetter%
echo.
%XCopy% "%DVD%" %USBDriveLetter% >nul
echo.-------------------------------------------------------------------------------
echo.####复制源文件夹到 USB 闪存驱动器已完成########################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set USBDriveLetter=
set USBDriveLabel=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 同步源启动和安装映像到 USB 闪存盘的模块
::-------------------------------------------------------------------------------------------
:SyncUSB

setlocal

set USBDriveLetter=
set USBDriveLabel=

cls
echo.===============================================================================
echo.              MSMG 工具箱 - 同步源启动和安装映像到 USB 闪存盘
echo.===============================================================================
echo.

:: 检查源文件是否被应用
if "%IsSourceSelected%" equ "Yes" (
	echo.当源操作系统被选择时，无法使用此功能……
	goto :Stop
)

:: 检查 Windows 源 DVD 文件夹是否是空的
if not exist "%BootWim%" (
	echo.Windows 安装源文件夹 ^<DVD^> 是空的……
	echo.
	echo.请复制安装源文件到 ^<DVD^> 文件夹……
	goto :Stop
)

:: 检查 Windows 源 DVD 文件夹是否是空的
if not exist "%InstallWim%" if not exist "%InstallEsd%" (
	echo.Windows 安装源文件夹 ^<DVD^> 是空的……
	echo.
	echo.请复制安装源文件到 ^<DVD^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始同步源启动和安装映像到 USB 闪存驱动器##############################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 USB 闪存驱动器选项################################################
echo.-------------------------------------------------------------------------------
echo.
:: 显示可用的 USB 闪存驱动器。
echo.正在列出可用的 USB 闪存驱动器……
call :ListDisks

:: 获取 USB 闪存驱动器盘符
set /p USBDriveLetter=请输入 USB 闪存驱动器盘符 ：

:: 设置 USB 闪存驱动器盘符
set "USBDriveLetter=%USBDriveLetter%:"
echo.
echo.-------------------------------------------------------------------------------
echo.####正在同步源启动和安装映像到 USB 闪存驱动器##################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在复制源启动和安装映像文件，请稍等……
echo.-------------------------------------------------------------------------------
echo.
echo.源文件 ： ^<\DVD\Sources\Boot.wim^>
if exist "%DVD%\Sources\install.wim" echo.         ^<\DVD\Sources\Install.wim^>
if exist "%DVD%\Sources\install.esd" echo.         ^<\DVD\Sources\Install.esd^>
echo.目  标 ： ^<%USBDriveLetter%\Sources^>
echo.
call :RemoveFile %USBDriveLetter%\Sources\Boot.wim
call :RemoveFile %USBDriveLetter%\Sources\Install.wim
call :RemoveFile %USBDriveLetter%\Sources\Install.esd

%XCopy% "%DVD%\Sources\boot.wim" %USBDriveLetter%\Sources
if exist "%DVD%\Sources\install.wim" %XCopy% "%DVD%\Sources\install.wim" %USBDriveLetter%\Sources
if exist "%DVD%\Sources\install.esd" %XCopy% "%DVD%\Sources\install.esd" %USBDriveLetter%\Sources
echo.
echo.-------------------------------------------------------------------------------
echo.####同步源启动和安装映像到 USB 闪存驱动器已完成################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set USBDriveLetter=
set USBDriveLabel=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 刻录 ISO 镜像到 USB 闪存驱动器模块
::-------------------------------------------------------------------------------------------
:BurnUSB

setlocal

set ISOFileName=
set USBDriveLetter=

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 刻录 ISO 镜像到 USB 闪存驱动器
echo.===============================================================================
echo.

:: 检查 ISO 文件夹是否是空的
if not exist "%ISO%\*.iso" (
	echo.ISO 镜像文件夹 ^<ISO^> 是空的……
	echo.
	echo.请复制 ISO 镜像到 ^<ISO^> 文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始刻录 ISO 镜像到 USB 闪存驱动器#####################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 ISO 镜像选项######################################################
echo.-------------------------------------------------------------------------------
echo.
:: 获取 ISO 文件名称
set /p ISOFileName=请输入 ISO 文件名称 ：

:: 设置 ISO 文件名称
set "ISOFileName=%ISOFileName%.iso"
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 USB 闪存驱动器选项################################################
echo.-------------------------------------------------------------------------------
echo.
:: 显示可用的 USB 闪存驱动器。
echo.正在列出可用的 USB 闪存驱动器……
call :ListDisks

:: 获取 USB 闪存驱动器盘符
set /p USBDriveLetter=请输入 USB 闪存驱动器盘符 ：

:: 设置 USB 闪存驱动器盘符
set "USBDriveLetter=%USBDriveLetter%:"

echo.
echo.-------------------------------------------------------------------------------
echo.####正在刻录 ISO 镜像到 USB 闪存驱动器#########################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在复制 ISO 镜像文件内容到 USB 闪存驱动器，请稍等……
echo.-------------------------------------------------------------------------------
echo.
echo.源 ISO 文件       ： %ISOFileName%
echo.目标驱动器        ： %USBDriveLetter%
echo.
%Zip% x -y "%ISO%\%ISOFileName%" -o"%USBDriveLetter%"
echo.
echo.-------------------------------------------------------------------------------
echo.####刻录 ISO 镜像到 USB 闪存驱动器已完成#######################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set ISOFileName=
set USBDriveLetter=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 格式化 USB 闪存驱动器模块
::-------------------------------------------------------------------------------------------
:FormatUSB

setlocal

set USBDriveLetter=
set USBDriveLabel=

cls
echo.===============================================================================
echo.                    MSMG 工具箱 - 格式化 USB 闪存驱动器
echo.===============================================================================
echo.
echo.-------------------------------------------------------------------------------
echo.####正在开始格式化 USB 闪存驱动器##############################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.####正在获取 USB 闪存驱动器选项################################################
echo.-------------------------------------------------------------------------------
echo.
:: 显示可用的 USB 闪存驱动器。
echo.正在列出可用的 USB 闪存驱动器……
call :ListDisks

:: 获取 USB 闪存驱动器盘符
set /p USBDriveLetter=请输入 USB 闪存驱动器盘符 ：
echo.

:: 设置 USB 闪存驱动器盘符
set "USBDriveLetter=%USBDriveLetter%:"

:: 检查指定的 USB 闪存驱动器是否存在
cd /d %USBDriveLetter% 2>nul
if errorlevel 1 (
	echo.指定的 USB 闪存驱动器无效，请再次尝试……
	goto :Stop
)

:: 获取 USB 闪存驱动器卷标。
set /p USBDriveLabel=Enter USB Flash Drive Volume Label : 
echo.

:: 获取 USB 引导类型（UEFI/BIOS/所有）。
choice /C 12 /N /M "请输入 USB 闪存驱动器的启动类型 [1=BIOS，2=BIOS/UEFI] ："
if errorlevel 2 goto :BIOS_UEFI
if errorlevel 1 goto :BIOS

:: 格式化 USB 闪存驱动器为 NTFS 格式，可用于 BIOS 引导系统。
:BIOS
	echo.
	choice /C:YN /N /M "你确定要格式化 [%USBDriveLetter%] 吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 (
		echo.
		echo.格式化 USB 闪存驱动器 [%USBDriveLetter%] 已取消……
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####格式化 USB 闪存驱动器已停止################################################
		echo.-------------------------------------------------------------------------------
		goto :Stop
	)
	if errorlevel 1 (
		call :FormatDisk %USBDriveLetter%, NTFS, %USBDriveLabel%
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####格式化 USB 闪存驱动器已完成################################################
		echo.-------------------------------------------------------------------------------
		goto :Stop
	)

:: 格式化 USB 闪存驱动器为 FAT32 格式，可用于 BIOS 和/或 UEFI 引导系统。
:BIOS_UEFI
	echo.
	choice /C:YN /N /M "你确定要格式化 [%USBDriveLetter%] 吗 ？ [是‘Y’/否‘N’] ："
	if errorlevel 2 (
		echo.
		echo.格式化 USB 闪存驱动器 [%USBDriveLetter%] 已取消……
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####格式化 USB 闪存驱动器已停止################################################
		echo.-------------------------------------------------------------------------------
		goto :Stop
	)
	if errorlevel 1 (
		call :FormatDisk %USBDriveLetter%, FAT32, %USBDriveLabel%
		echo.
		echo.-------------------------------------------------------------------------------
		echo.####格式化 USB 闪存驱动器已完成################################################
		echo.-------------------------------------------------------------------------------
		goto :Stop
	)

:Stop
echo.
echo.===============================================================================
echo.
pause

set USBDriveLetter=
set USBDriveLabel=

endlocal

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 列出所有硬盘和卷模块
:ListDisks

call :RemoveFile "%Temp%\DiskList.txt"
call :RemoveFile "%Temp%\DiskList1.txt"

echo.list volume>> "%Temp%\DiskList.txt"
diskpart /s "%Temp%\DiskList.txt" >> "%Temp%\DiskList1.txt"
call :RemoveFile "%Temp%\DiskList.txt"
echo.>> "%Temp%\DiskList.txt"

echo.===============================================================================>> "%Temp%\DiskList.txt"
if "%HostLanguage%" equ "en-US" echo.  Volume #  Letter Label      file Sys Type         Size    Status     Info>> "%Temp%\DiskList.txt"
if "%HostLanguage%" equ "zh-CN" echo.  卷 #      盘符   标签       文件系统  类型        大小    状态       信息>> "%Temp%\DiskList.txt"
echo.------------------------------------------------------------------------------->> "%Temp%\DiskList.txt"
if "%HostLanguage%" equ "en-US" findstr "Removable" "%Temp%\DiskList1.txt" >> "%Temp%\DiskList.txt"
if "%HostLanguage%" equ "zh-CN" findstr "可移动" "%Temp%\DiskList1.txt" >> "%Temp%\DiskList.txt"
echo.===============================================================================>> "%Temp%\DiskList.txt"

type "%Temp%\DiskList.txt"
call :RemoveFile "%Temp%\DiskList.txt"
call :RemoveFile "%Temp%\DiskList1.txt"
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 格式化硬盘/卷模块
:: 输入参数 [ %~1 ：USB 盘符、%~2 ：格式类型、%~3 ：卷标]
::-------------------------------------------------------------------------------------------
:FormatDisk

:: 写入 DiskPart.txt 脚本文件。
call :RemoveFile "%Temp%\DiskPart.txt"
echo.select volume ^%~1>> "%Temp%\DiskPart.txt"
echo.clean>> "%Temp%\DiskPart.txt"
echo.create partition primary>> "%Temp%\DiskPart.txt"
echo.select partition ^1>> "%Temp%\DiskPart.txt"
echo.active>> "%Temp%\DiskPart.txt"
echo.format fs=%~2 quick label=%~3>> "%Temp%\DiskPart.txt"
echo.exit>> "%Temp%\DiskPart.txt"
echo.exit>> "%Temp%\DiskPart.txt"
echo.
echo.-------------------------------------------------------------------------------
echo.####正在格式化 USB 闪存驱动器##################################################
echo.-------------------------------------------------------------------------------
echo.
:: 使用 Diskpart 执行 DiskPart.txt 脚本文件。
echo.正在格式化 USB 闪存驱动器 [%~1] 为 %~2 格式，请稍等……
start /B /wait diskpart /s "%Temp%\DiskPart.txt" >nul
echo.
echo.格式化 USB 闪存驱动器 [%~1] 为 %~2 格式，完成……
call :RemoveFile "%Temp%\DiskPart.txt"

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - WIM 管理器
::-------------------------------------------------------------------------------------------
:WIMManager

cls
echo.===============================================================================
echo.                          MSMG 工具箱 - WIM 管理器
echo.===============================================================================
echo.
:: 检查源文件是否被应用。
if "%IsSourceSelected%" equ "Yes" (
	echo.当源操作系统被选择时，无法使用此功能……
	echo.
	echo.===============================================================================
	echo.
	goto :Stop
)

echo.  [A]   显    示
echo.  [B]   重 命 名
echo.  [C]   删    除
echo.  [D]   导    出
echo.  [E]   拆    分
echo.  [F]   合    并
echo.  [G]   升    级
echo.  [H]   捕    获
echo.  [I]   应    用
echo.  [J]   清    理
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:ABCDEFGHIJX /N /M "请输入你的选项 ："
if errorlevel 11 goto :ToolsMenu
if errorlevel 10 goto :WIMCleanUp
if errorlevel 9  goto :WIMApply
if errorlevel 8  goto :WIMCapture
if errorlevel 7  goto :WIMUpgrade
if errorlevel 6  goto :WIMMerge
if errorlevel 5  goto :WIMSplit
if errorlevel 4  goto :WIMExport
if errorlevel 3  goto :WIMDelete
if errorlevel 2  goto :WIMRename
if errorlevel 1  goto :WIMDisplay

::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 显示 WIM 映像信息模块
::-------------------------------------------------------------------------------------------
:WIMDisplay

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 显示 WIM 映像信息
echo.===============================================================================

:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请将 Windows 安装程序中的“Install.wim”映像复制到相应的文件夹……
	echo.
	echo.===============================================================================
	echo.
	goto :Stop
)

:: 显示映像索引信息
call :ShowImageInfo

:Stop

pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 重命名 WIM 索引模块
::-------------------------------------------------------------------------------------------
:WIMRename

setlocal

set NewImageName=
set NewImageDescription=

cls
echo.===============================================================================
echo.                     MSMG 工具箱 - 重命名 WIM 映像索引
echo.===============================================================================
echo.

:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请复制 Windows 安装程序安装映像到相应的文件夹……
	goto :Stop
)

echo.-------------------------------------------------------------------------------
echo.####正在开始重命名源 WIM 映像索引##############################################
echo.-------------------------------------------------------------------------------

:: 显示映像索引信息
call :ShowImageInfo

:: 获取映像索引编号以重命名
if "%ImageCount%" equ "1" ( 
	set /p ImageIndexNo=请输入 WIM 映像索引号 ：
) else set /p ImageIndexNo=请输入 WIM 映像索引号的 [范围 ： 1-!ImageCount!] ：

if "%ImageIndexNo%" lss "1" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMRename
)

if "%ImageIndexNo%" gtr %ImageCount% (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMRename
)

echo.
set /p NewImageName=请输入 WIM 索引名称 ：
echo.
set /p NewImageDescription=请输入 WIM 索引描述 ：

echo.
echo.-------------------------------------------------------------------------------
echo.正在重命名源 WIM 映像 [Install.wim，索引 ：%ImageIndexNo%] 信息……
echo.-------------------------------------------------------------------------------
echo.
%WimLibImagex% info "%InstallWim%" %ImageIndexNo% "%NewImageName%" "%NewImageDescription%" --image-property DISPLAYNAME="%NewImageName%" --image-property DISPLAYDESCRIPTION="%NewImageDescription%"
echo.
echo.-------------------------------------------------------------------------------
echo.####重命名源 WIM 映像索引已完成################################################
echo.-------------------------------------------------------------------------------
:Stop
echo.
echo.===============================================================================
echo.
pause

set NewImageName=
set NewImageDescription=
set ImageIndexNo=

endlocal

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 删除 WIM 索引模块
::-------------------------------------------------------------------------------------------
:WIMDelete

cls
echo.===============================================================================
echo.                        MSMG 工具箱 - 删除 WIM 索引
echo.===============================================================================
echo.
:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请复制 Windows 安装程序安装映像到相应的文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始删除源 WIM 映像索引################################################
echo.-------------------------------------------------------------------------------

:: 显示映像信息
call :ShowImageInfo

:: 获取映像索引编号以删除
if "%ImageCount%" equ "1" ( 
	set /p ImageIndexNo=请输入 WIM 映像索引号 ：
) else set /p ImageIndexNo=请输入 WIM 映像索引号的 [范围 ： 1-!ImageCount!] ：

if "%ImageIndexNo%" lss "1" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMDelete
)

if "%ImageIndexNo%" gtr %ImageCount% (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMDelete
)

echo.
echo.-------------------------------------------------------------------------------
echo.正在删除源 WIM 映像 [Install.wim，索引 ：%ImageIndexNo%]……
echo.-------------------------------------------------------------------------------

call :DeleteImage "%InstallWim%", %ImageIndexNo%

echo.-------------------------------------------------------------------------------
echo.####删除源 WIM 映像索引已完成##################################################
echo.-------------------------------------------------------------------------------
:Stop
echo.
echo.===============================================================================
echo.
pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 导出 WIM 索引到源 WIM 映像或新的 WIM 映像模块
::-------------------------------------------------------------------------------------------
:WIMExport

setlocal

set WimImageFileName=
 
cls
echo.===============================================================================
echo.                        MSMG 工具箱 - 导出 WIM 索引
echo.===============================================================================
echo.
:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请复制 Windows 安装程序安装映像到相应的文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始导出源 WIM 映像索引################################################
echo.-------------------------------------------------------------------------------

:: 显示映像信息
call :ShowImageInfo

:: 获取映像索引编号以导出
if "%ImageCount%" equ "1" ( 
	set /p ImageIndexNo=请输入 WIM 映像索引号 ：
) else set /p ImageIndexNo=请输入 WIM 映像索引号的 [范围 ： 1-!ImageCount!] ：

if "%ImageIndexNo%" lss "1" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMExport
)

if "%ImageIndexNo%" gtr %ImageCount% (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMExport
)

echo.
choice /C:YN /N /M "你想要导出为新的 WIM 映像吗 ？ [是‘Y’/否‘N’] ："
if errorlevel 2 goto :Export2SameImage
if not errorlevel 2 goto :Export2NewImage

:Export2SameImage
	set "WimImageFileName=%InstallWim%"
	echo.
	echo.-------------------------------------------------------------------------------
	echo.正在导出源 WIM 映像 [Install.wim，索引 ：%ImageIndexNo%] 为 [Install.wim]……
	echo.-------------------------------------------------------------------------------
	call :ExportImageIndex "%InstallWim%", %ImageIndexNo%, %WimImageFileName%, "WIM", "No"
	goto :Continue

:Export2NewImage
	echo.
	set /p WimImageFileName=请输入 WIM 映像文件名称，不含 [.wim] ：
	set "WimImageFileName=%WimImageFileName%.wim"
	echo.	  
	echo.-------------------------------------------------------------------------------
	echo.正在导出源 WIM 映像 [Install.wim，索引 ：%ImageIndexNo%] 为 [%WimImageFileName%]……
	echo.-------------------------------------------------------------------------------
	call :ExportImageIndex "%InstallWim%", %ImageIndexNo%, "%DVD%\sources\%WimImageFileName%", "WIM", "No"
	goto :Continue
	
:Continue
	echo.-------------------------------------------------------------------------------
	echo.####导出源 WIM 映像索引已完成##################################################
	echo.-------------------------------------------------------------------------------
:Stop
echo.
echo.===============================================================================
echo.
pause

set WimImageFileName=

endlocal

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 拆分 WIM 映像模块
::-------------------------------------------------------------------------------------------
:WIMSplit

setlocal

set WimImageSplitFileSize=

cls
echo.===============================================================================
echo.                        MSMG 工具箱 - 拆分 WIM 映像
echo.===============================================================================
echo.
:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请复制 Windows 安装程序安装映像到相应的文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始拆分源 WIM 映像####################################################
echo.-------------------------------------------------------------------------------
echo.
set /p WimImageSplitFileSize=请输入 WIM 映像拆分文件大小，单位 MB ：
echo.
echo.-------------------------------------------------------------------------------
echo.正在拆分源 WIM 映像 [Install.wim]……
echo.-------------------------------------------------------------------------------

call :SplitImage "%InstallWim%", "%DVD%\sources\install.swm", %WimImageSplitFileSize%
call :RemoveFile "%InstallWim%"

echo.-------------------------------------------------------------------------------
echo.####拆分源 WIM 映像已完成######################################################
echo.-------------------------------------------------------------------------------
:Stop
echo.
echo.===============================================================================
echo.
pause

set WimImageSplitFileSize=

endlocal

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 合并已拆分的 WIM 映像模块
::-------------------------------------------------------------------------------------------
:WIMMerge

cls
echo.===============================================================================
echo.                    MSMG 工具箱 - 合并已拆分的 WIM 映像
echo.===============================================================================
echo.
:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请复制 Windows 安装程序安装映像到相应的文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始合并已拆分的源 WIM 映像############################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在合并已拆分的源 WIM 映像 [Install.swm] 为 [Install.wim]……
echo.-------------------------------------------------------------------------------

call :MergeImage "%DVD%\sources\install", "%InstallWim%"
call :RemoveFile "%DVD%\sources\*.swm"

echo.-------------------------------------------------------------------------------
echo.####合并已拆分的源 WIM 映像已完成##############################################
echo.-------------------------------------------------------------------------------
:Stop
echo.
echo.===============================================================================
echo.
pause

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 升级 WIM 索引版本模块
::-------------------------------------------------------------------------------------------
:WIMUpgrade

setlocal

set SourceEdition=
set TargetEdition=
set Flag=
set Edition=
set Name=
set Description=
set DisplayName=
set DisplayDescription=

cls
echo.===============================================================================
echo.                        MSMG 工具箱 - 升级 WIM 版本
echo.===============================================================================

:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请复制 Windows 安装程序安装映像到相应的文件夹……
	goto :Stop
)

:: 获取映像索引号以维护
call :GetImageIndexNo "%InstallWim%"

:: 检查映像索引有效性
if "%ImageIndexNo%" equ "" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul
	goto :SelectSourceDVD
)

:: 检查映像索引有效性
if "%ImageIndexNo%" neq "*" if "%ImageIndexNo%" lss "1" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul
	goto :SelectSourceDVD
)

:: 检查映像索引有效性
if "%ImageIndexNo%" neq "*" if "%ImageIndexNo%" gtr %ImageCount% (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul
	goto :SelectSourceDVD
)

:: 获取所选择的映像索引信息
if "%ImageIndexNo%" equ "*" call :GetImageIndexInfo "%InstallWim%", 1 >nul
if "%ImageIndexNo%" neq "*" call :GetImageIndexInfo "%InstallWim%", %ImageIndexNo% >nul

:: 设置所选择的源操作系统版本
if "%ImageVersion%" equ "6.1.7601" set "SelectedSourceOS=w7"
if "%ImageVersion%" equ "6.3.9600" set "SelectedSourceOS=w81"
if "%ImageVersion:~0,-6%" equ "10.0" set "SelectedSourceOS=w10"

echo.

:: 检查所选择的源操作系统是否是 Windows 7 企业版
if "%SelectedSourceOS%" equ "w7" if "%ImageFlag%" equ "Enterprise" (
	echo.Windows 7 企业版无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 7 企业版 N
if "%SelectedSourceOS%" equ "w7" if "%ImageFlag%" equ "EnterpriseN" (
	echo.Windows 7 企业版 N 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 7 企业版 K
if "%SelectedSourceOS%" equ "w7" if "%ImageFlag%" equ "EnterpriseK" (
	echo.Windows 7 企业版 K 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 7 企业版 KN
if "%SelectedSourceOS%" equ "w7" if "%ImageFlag%" equ "EnterpriseKN" (
	echo.Windows 7 企业版 KN 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 7 旗舰版
if "%SelectedSourceOS%" equ "w7" if "%ImageFlag%" equ "Ultimate" (
	echo.Windows 7 旗舰版无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 7 旗舰版 N
if "%SelectedSourceOS%" equ "w7" if "%ImageFlag%" equ "UltimateN" (
	echo.Windows 7 旗舰版 N 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 7 旗舰版 K
if "%SelectedSourceOS%" equ "w7" if "%ImageFlag%" equ "UltimateK" (
	echo.Windows 7 旗舰版 K 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 7 旗舰版 KN
if "%SelectedSourceOS%" equ "w7" if "%ImageFlag%" equ "UltimateKN" (
	echo.Windows 7 旗舰版 KN 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 8.1 专业版 (含 Media Center)
if "%ImageFlag%" equ "ProfessionalWMC" (
	echo.Windows 8.1 专业版 ^(含 Media Center^) 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 8.1 专业版 N
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "ProfessionalN" (
	echo.Windows 8.1 专业版 N 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 8.1 企业版
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "Enterprise" (
	echo.Windows 8.1 企业版无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 8.1 企业版 N
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "EnterpriseN" (
	echo.Windows 8.1 企业版 N 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 8.1 Embedded Industry Pro/Enterprise Edition
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "EmbeddedIndustry" (
	echo.Windows Embedded 8.1 Industry Pro 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 8.1 Embedded Industry Enterprise Edition
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "EmbeddedIndustryE" (
	echo.Windows Embedded 8.1 Industry Enterprise 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows Server 2012 R2 Datacenter Core 版本
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "ServerDataCenterCore" (
	echo.Windows Server 2012 R2 Datacenter Core 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows Server 2012 R2 Datacenter
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "ServerDataCenter" (
	echo.Windows Server 2012 R2 Datacenter 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows Server 2012 R2 Foundation
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "ServerWinFoundation" (
	echo.Windows Server 2012 R2 Foundation 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows Storage Server 2012 R2 Standard
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "ServerStorageStandard" (
	echo.Windows Storage Server 2012 R2 Standard 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows Storage Server 2012 R2 Workgroup
if "%SelectedSourceOS%" equ "w81" if "%ImageFlag%" equ "ServerStorageWorkgroup" (
	echo.Windows Storage Server 2012 R2 Workgroup 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)
	
:: 检查所选择的源操作系统是否是 Windows 10 企业版
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10240" if "%ImageFlag%" equ "Enterprise" (
	echo.Windows 10 企业版无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 N
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "10240" if "%ImageFlag%" equ "EnterpriseN" (
	echo.Windows 10 企业版 N 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 S Edition
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "Cloud" (
	echo.Windows 10 S 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 S N Edition
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "16299" if "%ImageEdition%" equ "CloudN" (
	echo.Windows 10 S N 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)
	
:: 检查所选择的源操作系统是否是 Windows 10 专业版
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "16299" if "%ImageFlag%" equ "Professional" (
	echo.Windows 10 专业版无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)
	
:: 检查所选择的源操作系统是否是 Windows 10 专业版 N
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "16299" if "%ImageFlag%" equ "ProfessionalN" (
	echo.Windows 10 专业版 N 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)
		
:: 检查所选择的源操作系统是否是 Windows 10 企业版 G
if "%ImageFlag%" equ "EnterpriseG" (
	echo.Windows 10 企业版 G 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 GN
if "%ImageFlag%" equ "EnterpriseGN" (
	echo.Windows 10 企业版 GN 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 LTSB
if "%ImageFlag%" equ "EnterpriseS" (
	if "%ImageBuild%" equ "10240" echo.Windows 10 企业版 2015 LTSB 无法升级……
	if "%ImageBuild%" equ "14393" echo.Windows 10 企业版 2016 LTSB 无法升级……
	if "%ImageBuild%" equ "17763" echo.Windows 10 企业版 2019 LTSC 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 企业版 N LTSB
if "%ImageFlag%" equ "EnterpriseSN" (
	if "%ImageBuild%" equ "10240" echo.Windows 10 企业版 N 2015 LTSB 无法升级……
	if "%ImageBuild%" equ "14393" echo.Windows 10 企业版 N 2016 LTSB 无法升级……
	if "%ImageBuild%" equ "17763" echo.Windows 10 企业版 N 2019 LTSC 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 教育版
if "%ImageFlag%" equ "Education" (
	echo.Windows 10 教育版无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows 10 教育版 N
if "%ImageFlag%" equ "EducationN" (
	echo.Windows 10 教育版 N 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows Hyper Server 2016 Edition
if "%SelectedSourceOS%" equ "w10" if "%ImageFlag%" equ "ServerHyper" (
	echo.Windows Hyper-V Server 2016 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu 
)   

:: 检查所选择的源操作系统是否是 Windows Server 2016 Azure Core 版本
if "%SelectedSourceOS%" equ "w10" if "%ImageFlag%" equ "ServerAzureCor" (
	echo.Windows Server 2016 Azure Core 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu 
)

:: 检查所选择的源操作系统是否是 Windows Server 2016 Datacenter
if "%SelectedSourceOS%" equ "w10" if "%ImageFlag%" equ "ServerDatacenter" (
	echo.Windows Server 2016 Datacenter 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu 
)

:: 检查所选择的源操作系统是否是 Windows Storage Server 2016 Standard
if "%SelectedSourceOS%" equ "w10" if "%ImageFlag%" equ "ServerStorageStandard" (
	echo.Windows Storage Server 2016 Standard 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu
)

:: 检查所选择的源操作系统是否是 Windows Storage Server 2016 Workgroup
if "%SelectedSourceOS%" equ "w10" if "%ImageFlag%" equ "ServerStorageWorkgroup" (
	echo.Windows Storage Server 2016 Workgroup 无法升级……
	echo.
	echo.===============================================================================
	echo.
	pause
	goto :MainMenu 
)

set SourceEdition=%ImageFlag%

echo.-------------------------------------------------------------------------------
echo.####正在开始升级 WIM 映像版本##################################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在将 [Install.wim，索引 ：%ImageIndexNo%] 映像安装在 ^<\Mount\Install^>……
echo.-------------------------------------------------------------------------------
call :MountImage "%InstallWim%", %ImageIndexNo%, "%InstallMount%"
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在获取目标版本……
echo.-------------------------------------------------------------------------------
echo.
for /f "tokens=2 delims=:" %%a in ('%DISM% /Image:"%InstallMount%" /Get-TargetEditions ^| find "Target Edition"') do (echo. %%a)
echo.
:: 获取目标版本
set /p TargetEdition=请输入目标版本 ： 
echo.

:: 检查所选择的源操作系统是否是 Windows 8.1 专业版零售版本
if "%SelectedSourceOS%" equ "w81" if "%ImageEdition%" equ "Professional" if "%TargetEdition%" equ "ProfessionalWMC" (
	echo.正在检查源映像是否是 Windows 8.1 专业版……
	echo.
	%DISM% /Format:Table /Image:"%InstallMount%" /Get-Packages | findstr /c:"GVLK-Package" >nul
	if not errorlevel 1 (
		echo.所选择的源文件不是 Windows 8.1 专业版零售版本……
		echo.
		echo.请使用 Windows 8.1 专业版零售版本操作系统作为源文件……
		goto :Stop
	)
)
echo.-------------------------------------------------------------------------------
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType%" equ "Client" echo.正在将 Windows 7 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w7" if "%ImageInstallationType:~,6%" equ "Server" echo.正在将 Windows Server 2008 R2 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType%" equ "Client" echo.正在将 Windows 8.1 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType%" equ "Embedded" echo.正在将 Windows 8.1 Embedded %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w81" if "%ImageInstallationType:~,6%" equ "Server" echo.正在将 Windows Server 2012 R2 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w10" if "%ImageInstallationType%" equ "Client" echo.正在将 Windows 10 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType:~,6%" equ "Server" echo.正在将 Windows Server 2016 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "15063" if "%ImageInstallationType:~,6%" equ "Server" echo.正在将 Windows Server v1709 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "16299" if "%ImageInstallationType:~,6%" equ "Server" echo.正在将 Windows Server v1803 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17134" if "%ImageInstallationType:~,6%" equ "Server" echo.正在将 Windows Server v1809 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType:~,6%" equ "Server" echo.正在将 Windows Server 2019 %SourceEdition% 升级到 %TargetEdition%……
if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "18362" if "%ImageInstallationType:~,6%" equ "Server" echo.正在将 Windows Server v1903/v1909 %SourceEdition% 升级到 %TargetEdition%……

echo.-------------------------------------------------------------------------------
%DISM% /Image:"%InstallMount%" /Set-Edition:%TargetEdition%
echo.
echo.-------------------------------------------------------------------------------
echo.正在卸载源 [Install.wim，索引 ：%ImageIndexNo%] 映像……
echo.-------------------------------------------------------------------------------
call :UnMountImage "%InstallMount%", "Commit"
echo.-------------------------------------------------------------------------------
echo.####正在应用目标 WIM 映像版本属性##############################################
echo.-------------------------------------------------------------------------------
echo.
if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "HomeBasic" (
	set "Flag=HomeBasic"
	set "Edition=HomeBasic"
	set "Name=Windows 7 HOMEBASIC"
	set "Description=Windows 7 HOMEBASIC"
	set "DisplayName=Windows 7 家庭普通版"
	set "DisplayDescription=Windows 7 家庭普通版"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "HomePremium" (
	set "Flag=HomePremium"
	set "Edition=HomePremium"
	set "Name=Windows 7 HOMEPREMIUM"
	set "Description=Windows 7 HOMEPREMIUM"
	set "DisplayName=Windows 7 家庭高级版"
	set "DisplayDescription=Windows 7 家庭高级版"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "Professional" (
	set "Flag=Professional"
	set "Edition=Professional"
	set "Name=Windows 7 PROFESSIONAL"
	set "Description=Windows 7 PROFESSIONAL"
	set "DisplayName=Windows 7 专业版"
	set "DisplayDescription=Windows 7 专业版"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "Ultimate" (
	set "Flag=Ultimate"
	set "Edition=Ultimate"
	set "Name=Windows 7 ULTIMATE"
	set "Description=Windows 7 ULTIMATE"
	set "DisplayName=Windows 7 旗舰版"
	set "DisplayDescription=Windows 7 旗舰版"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "HomeBasicN" (
	set "Flag=HomeBasicN"
	set "Edition=HomeBasicN"
	set "Name=Windows 7 HOMEBASICN"
	set "Description=Windows 7 HOMEBASICN"
	set "DisplayName=Windows 7 家庭普通版 N"
	set "DisplayDescription=Windows 7 家庭普通版 N"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "HomePremiumN" (
	set "Flag=HomePremiumN"
	set "Edition=HomePremiumN"
	set "Name=Windows 7 HOMEPREMIUMN"
	set "Description=Windows 7 HOMEPREMIUMN"
	set "DisplayName=Windows 7 家庭高级版 N"
	set "DisplayDescription=Windows 7 家庭高级版 N"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "ProfessionalN" (
	set "Flag=ProfessionalN"
	set "Edition=ProfessionalN"
	set "Name=Windows 7 PROFESSIONALN"
	set "Description=Windows 7 PROFESSIONALN"
	set "DisplayName=Windows 7 专业版 N"
	set "DisplayDescription=Windows 7 专业版 N"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "UltimateN" (
	set "Flag=UltimateN"
	set "Edition=UltimateN"
	set "Name=Windows 7 ULTIMATEN"
	set "Description=Windows 7 ULTIMATEN"
	set "DisplayName=Windows 7 旗舰版 N"
	set "DisplayDescription=Windows 7 旗舰版 N"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "HomeBasicK" (
	set "Flag=HomeBasicK"
	set "Edition=HomeBasicK"
	set "Name=Windows 7 HOMEBASICK"
	set "Description=Windows 7 HOMEBASICK"
	set "DisplayName=Windows 7 家庭普通版 K"
	set "DisplayDescription=Windows 7 家庭普通版 K"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "HomePremiumK" (
	set "Flag=HomePremiumK"
	set "Edition=HomePremiumK"
	set "Name=Windows 7 HOMEPREMIUMK"
	set "Description=Windows 7 HOMEPREMIUMK"
	set "DisplayName=Windows 7 家庭高级版 K"
	set "DisplayDescription=Windows 7 家庭高级版 K"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "ProfessionalK" (
	set "Flag=ProfessionalK"
	set "Edition=ProfessionalK"
	set "Name=Windows 7 PROFESSIONALK"
	set "Description=Windows 7 PROFESSIONALK"
	set "DisplayName=Windows 7 专业版 K"
	set "DisplayDescription=Windows 7 专业版 K"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "UltimateK" (
	set "Flag=UltimateK"
	set "Edition=UltimateK"
	set "Name=Windows 7 ULTIMATEK"
	set "Description=Windows 7 ULTIMATEK"
	set "DisplayName=Windows 7 旗舰版 K"
	set "DisplayDescription=Windows 7 旗舰版 K"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "HomeBasicKN" (
	set "Flag=HomeBasicKN"
	set "Edition=HomeBasicKN"
	set "Name=Windows 7 HOMEBASICKN"
	set "Description=Windows 7 HOMEBASICKN"
	set "DisplayName=Windows 7 家庭普通版 KN"
	set "DisplayDescription=Windows 7 家庭普通版 KN"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "HomePremiumKN" (
	set "Flag=HomePremiumKN"
	set "Edition=HomePremiumKN"
	set "Name=Windows 7 HOMEPREMIUMKN"
	set "Description=Windows 7 HOMEPREMIUMKN"
	set "DisplayName=Windows 7 家庭高级版 KN"
	set "DisplayDescription=Windows 7 家庭高级版 KN"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "ProfessionalKN" (
	set "Flag=ProfessionalKN"
	set "Edition=ProfessionalKN"
	set "Name=Windows 7 PROFESSIONALKN"
	set "Description=Windows 7 PROFESSIONALKN"
	set "DisplayName=Windows 7 专业版 KN"
	set "DisplayDescription=Windows 7 专业版 KN"
)

if "%SelectedSourceOS%" equ "w7"  if "%TargetEdition%" equ "UltimateKN" (
	set "Flag=UltimateKN"
	set "Edition=UltimateKN"
	set "Name=Windows 7 ULTIMATEKN"
	set "Description=Windows 7 ULTIMATEKN"
	set "DisplayName=Windows 7 旗舰版 KN"
	set "DisplayDescription=Windows 7 旗舰版 KN"
)

if "%SelectedSourceOS%" equ "w7" if "%TargetEdition%" equ "ServerStandardCore" (
	set "Flag=ServerStandardCore"
	set "Edition=ServerStandard"
	set "Name=Windows Server 2008 R2 SERVERSTANDARDCORE"
	set "Description=Windows Server 2008 R2 SERVERSTANDARDCORE"
	set "DisplayName=Windows Server 2008 R2 Standard ^(服务器核心安装^)"
	set "DisplayDescription=此选项将在没有标准 Windows 用户界面的情况下安装 Windows Server 的最小版本，并且可以安装可以从命令提示符管理的服务器角色子集，从而降低管理要求和攻击面。"
)

if "%SelectedSourceOS%" equ "w7" if "%TargetEdition%" equ "ServerEnterpriseCore" (
	set "Flag=ServerEnterpriseCore"
	set "Edition=ServerEnterprise"
	set "Name=Windows Server 2008 R2 SERVERENTERPRISECORE"
	set "Description=Windows Server 2008 R2 SERVERENTERPRISECORE"
	set "DisplayName=Windows Server 2008 R2 Enterprise ^(服务器核心安装^)"
	set "DisplayDescription=此选项将在没有标准 Windows 用户界面的情况下安装 Windows Server 的最小版本，并且可以安装可以从命令提示符管理的服务器角色子集，从而降低管理要求和攻击面。"
)

if "%SelectedSourceOS%" equ "w7" if "%TargetEdition%" equ "ServerDatacenterCore" (
	set "Flag=ServerDataCenterCore"
	set "Edition=ServerDatacenter"
	set "Name=Windows Server 2008 R2 SERVERDATACENTERCORE"
	set "Description=Windows Server 2008 R2 SERVERDATACENTERCORE"
	set "DisplayName=Windows Server 2008 R2 Datacenter ^(服务器核心安装^)"
	set "DisplayDescription=此选项将在没有标准 Windows 用户界面的情况下安装 Windows Server 的最小版本，并且可以安装可以从命令提示符管理的服务器角色子集，从而降低管理要求和攻击面。"
)

if "%SelectedSourceOS%" equ "w7" if "%TargetEdition%" equ "ServerStandard" (
	set "Flag=ServerStandard"
	set "Edition=ServerStandard"
	set "Name=Windows Server 2008 R2 SERVERSTANDARD"
	set "Description=Windows Server 2008 R2 SERVERSTANDARD"
	set "DisplayName=Windows Server 2008 R2 Standard ^(完整安装^)"
	set "DisplayDescription=此选项将安装 Windows Server 的完整版本。此安装包括整个用户界面，并且它支持所有的服务器角色。"
)

if "%SelectedSourceOS%" equ "w7" if "%TargetEdition%" equ "ServerEnterprise" (
	set "Flag=ServerEnterprise"
	set "Edition=ServerEnterprise"
	set "Name=Windows Server 2008 R2 SERVERENTERPRISE"
	set "Description=Windows Server 2008 R2 SERVERENTERPRISE"
	set "DisplayName=Windows Server 2008 R2 Enterprise ^(完整安装^)"
	set "DisplayDescription=此选项将安装 Windows Server 的完整版本。此安装包括整个用户界面，并且它支持所有的服务器角色。"
)

if "%SelectedSourceOS%" equ "w7" if "%TargetEdition%" equ "ServerDatacenter" (
	set "Flag=ServerDataCenter"
	set "Edition=ServerDatacenter"
	set "Name=Windows Server 2008 R2 SERVERDATACENTER"
	set "Description=Windows Server 2008 R2 SERVERDATACENTER"
	set "DisplayName=Windows Server 2008 R2 Datacenter ^(完整安装^)"
	set "DisplayDescription=此选项将安装 Windows Server 的完整版本。此安装包括整个用户界面，并且它支持所有的服务器角色。"
)

if "%SelectedSourceOS%" equ "w81" if "%TargetEdition%" equ "Core" (
	set "Flag=Core"
	set "Edition=Core"
	set "Name=Windows 8.1 Core"
	set "Description=Windows 8.1 Core"
	set "DisplayName=Windows 8.1 Core"
	set "DisplayDescription=Windows 8.1 Core"
)

if "%SelectedSourceOS%" equ "w81" if "%TargetEdition%" equ "Professional" (
	set "Flag=Professional"
	set "Edition=Professional"
	set "Name=Windows 8.1 专业版"
	set "Description=Windows 8.1 专业版"
	set "DisplayName=Windows 8.1 专业版"
	set "DisplayDescription=Windows 8.1 专业版"
)

if "%SelectedSourceOS%" equ "w81" if "%TargetEdition%" equ "ProfessionalWMC" (
	set "Flag=ProfessionalWMC"
	set "Edition=ProfessionalWMC"
	set "Name=Windows 8.1 专业版 WMC"
	set "Description=Windows 8.1 专业版 WMC"
	set "DisplayName=Windows 8.1 专业版^(含 Media Center^)"
	set "DisplayDescription=Windows 8.1 专业版^(含 Media Center^)"
)

if "%SelectedSourceOS%" equ "w81" if "%TargetEdition%" equ "ProfessionalN" (
	set "Flag=ProfessionalN"
	set "Edition=ProfessionalN"
	set "Name=Windows 8.1 专业版 N"
	set "Description=Windows 8.1 专业版 N"
	set "DisplayName=Windows 8.1 专业版 N"
	set "DisplayDescription=Windows 8.1 专业版 N"
)

if "%SelectedSourceOS%" equ "w81" if "%TargetEdition%" equ "ServerDatacenterCore" (
	set "Flag=ServerDatacenterCore"
	set "Edition=ServerDatacenterCore"
	set "Name=Windows Server 2012 R2 Datacenter ^(服务器核心安装^)"
	set "Description=此选项 ^(推荐^) 通过仅安装运行大多数服务器角色和应用程序所需的组件来减少管理和服务。它不包括 GUI，但是您可以使用 Windows PowerShell 或其他工具在本地或远程完全管理服务器。你可以稍后切换到其他安装选项。 请参阅“Windows Server 安装选项。”"
	set "DisplayName=Windows Server 2012 R2 Datacenter ^(服务器核心安装^)"
	set "DisplayDescription=此选项 ^(推荐^) 通过仅安装运行大多数服务器角色和应用程序所需的组件来减少管理和服务。它不包括 GUI，但是您可以使用 Windows PowerShell 或其他工具在本地或远程完全管理服务器。你可以稍后切换到其他安装选项。 请参阅“Windows Server 安装选项。”"
)

if "%SelectedSourceOS%" equ "w81" if "%TargetEdition%" equ "ServerStandard" (
	set "Flag=ServerStandard"
	set "Edition=ServerStandard"
	set "Name=Windows Server 2012 R2 Standard ^(服务器含 GUI^)"
	set "Description=当需要 GUI 时，此选项很有用——例如，为无法在服务器核心安装上运行的应用程序提供向后兼容性。支持所有的服务器角色和功能。你可以在以后切换到其他安装选项。请参阅“Windows Server 安装选项”。"
	set "DisplayName=Windows Server 2012 R2 Standard ^(服务器含 GUI^)"
	set "DisplayDescription=当需要 GUI 时，此选项很有用——例如，为无法在服务器核心安装上运行的应用程序提供向后兼容性。支持所有的服务器角色和功能。你可以在以后切换到其他安装选项。请参阅“Windows Server 安装选项”。"
)

if "%SelectedSourceOS%" equ "w81" if "%TargetEdition%" equ "ServerDatacenter" (
	set "Flag=ServerDatacenter"
	set "Edition=ServerDatacenter"
	set "Name=Windows Server 2012 R2 Datacenter ^(服务器含 GUI^)"
	set "Description=当需要 GUI 时，此选项很有用——例如，为无法在服务器核心安装上运行的应用程序提供向后兼容性。支持所有的服务器角色和功能。你可以在以后切换到其他安装选项。请参阅“Windows Server 安装选项”。"
	set "DisplayName=Windows Server 2012 R2 Datacenter ^(服务器含 GUI^)"
	set "DisplayDescription=当需要 GUI 时，此选项很有用——例如，为无法在服务器核心安装上运行的应用程序提供向后兼容性。支持所有的服务器角色和功能。你可以在以后切换到其他安装选项。请参阅“Windows Server 安装选项”。"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "Core" (
	set "Flag=Core"
	set "Edition=Core"
	set "Name=Windows 10 家庭版"
	set "Description=Windows 10 家庭版"
	set "DisplayName=Windows 10 家庭版"
	set "DisplayDescription=Windows 10 家庭版"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "CoreN" (
	set "Flag=CoreN"
	set "Edition=CoreN"
	set "Name=Windows 10 家庭版 N"
	set "Description=Windows 10 家庭版 N"
	set "DisplayName=Windows 10 家庭版 N"
	set "DisplayDescription=Windows 10 家庭版 N"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "Professional" (
	set "Flag=Professional"
	set "Edition=Professional"
	set "Name=Windows 10 专业版"
	set "Description=Windows 10 专业版"
	set "DisplayName=Windows 10 专业版"
	set "DisplayDescription=Windows 10 专业版"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "ProfessionalN" (
	set "Flag=ProfessionalN"
	set "Edition=ProfessionalN"
	set "Name=Windows 10 专业版 N"
	set "Description=Windows 10 专业版 N"
	set "DisplayName=Windows 10 专业版 N"
	set "DisplayDescription=Windows 10 专业版 N"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "ProfessionalCountrySpecific" (
	set "Flag=ProfessionalCountrySpecific"
	set "Edition=ProfessionalCountrySpecific"
	set "Name=Windows 10 专业中文版"
	set "Description=Windows 10 专业中文版"
	set "DisplayName=Windows 10 专业中文版"
	set "DisplayDescription=Windows 10 专业中文版"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "ProfessionalSingleLanguage" (
	set "Flag=ProfessionalSingleLanguage"
	set "Edition=ProfessionalSingleLanguage"
	set "Name=Windows 10 专业单语言版"
	set "Description=Windows 10 专业单语言版"
	set "DisplayName=Windows 10 专业单语言版""
	set "DisplayDescription=Windows 10 专业单语言版"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "Education" (
	set "Flag=Education"
	set "Edition=Education"
	set "Name=Windows 10 教育版"
	set "Description=Windows 10 教育版"
	set "DisplayName=Windows 10 教育版"
	set "DisplayDescription=Windows 10 教育版"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "EducationN" (
	set "Flag=EducationN"
	set "Edition=EducationN"
	set "Name=Windows 10 教育版 N"
	set "Description=Windows 10 教育版 N"
	set "DisplayName=Windows 10 教育版 N"
	set "DisplayDescription=Windows 10 教育版 N"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "Enterprise" (
	set "Flag=Enterprise"
	set "Edition=Enterprise"
	set "Name=Windows 10 企业版"
	set "Description=Windows 10 企业版"
	set "DisplayName=Windows 10 企业版"
	set "DisplayDescription=Windows 10 企业版"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "EnterpriseN" (
	set "Flag=EnterpriseN"
	set "Edition=EnterpriseN"
	set "Name=Windows 10 企业版 N"
	set "Description=Windows 10 企业版 N"
	set "DisplayName=Windows 10 企业版 N"
	set "DisplayDescription=Windows 10 企业版 N"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "EnterpriseG" (
	set "Flag=EnterpriseG"
	set "Edition=EnterpriseG"
	set "Name=Windows 10 企业版 G"
	set "Description=Windows 10 企业版 G"
	set "DisplayName=Windows 10 企业版 G"
	set "DisplayDescription=Windows 10 企业版 G"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "EnterpriseGN" (
	set "Flag=EnterpriseGN"
	set "Edition=EnterpriseGN"
	set "Name=Windows 10 企业版 GN"
	set "Description=Windows 10 企业版 GN"
	set "DisplayName=Windows 10 企业版 GN"
	set "DisplayDescription=Windows 10 企业版 GN"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "ProfessionalEducation" (
	set "Flag=ProfessionalEducation"
	set "Edition=ProfessionalEducation"
	set "Name=Windows 10 专业教育版"
	set "Description=Windows 10 专业教育版"
	set "DisplayName=Windows 10 专业教育版"
	set "DisplayDescription=Windows 10 专业教育版"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "ProfessionalEducationN" (
	set "Flag=ProfessionalEducationN"
	set "Edition=ProfessionalEducationN"
	set "Name=Windows 10 专业教育版N"
	set "Description=Windows 10 专业教育版 N"
	set "DisplayName=Windows 10 专业教育版 N"
	set "DisplayDescription=Windows 10 专业教育版 N"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "ProfessionalWorkstation" (
	set "Flag=ProfessionalWorkstation"
	set "Edition=ProfessionalWorkstation"
	set "Name=Windows 10 专业工作站版"
	set "Description=Windows 10 专业工作站版"
	set "DisplayName=Windows 10 专业工作站版"
	set "DisplayDescription=Windows 10 专业工作站版"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "ProfessionalWorkstationN" (
	set "Flag=ProfessionalWorkstationN"
	set "Edition=ProfessionalWorkstationN"
	set "Name=Windows 10 专业工作站版 N"
	set "Description=Windows 10 专业工作站版 N"
	set "DisplayName=Windows 10 专业工作站版 N"
	set "DisplayDescription=Windows 10 专业工作站版 N"
)

if "%SelectedSourceOS%" equ "w10" if "%TargetEdition%" equ "ServerRdsh" (
	set "Flag=ServerRdsh"
	set "Edition=ServerRdsh"
	set "Name=适用于虚拟桌面的 Windows 10 企业版"
	set "Description=适用于虚拟桌面的 Windows 10 企业版"
	set "DisplayName=适用于虚拟桌面的 Windows 10 企业版"
	set "DisplayDescription=适用于虚拟桌面的 Windows 10 企业版"
)

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Server Core" if "%SourceEdition%" equ "ServerStandard" if "%TargetEdition%" equ "ServerAzureCor" (
	set "Flag=ServerAzureCor"
	set "Edition=ServerAzureCor"
	set "Name=Windows Server 2016 SERVERAZURECORE"
	set "Description=Windows Server 2016 SERVERAZURECORE"
	set "DisplayName=Windows Server 2016 Azure"
	set "DisplayDescription=此选项^(推荐^)通过仅安装运行大多数服务器角色和应用程序所需的内容来减少管理和服务。它不包含 GUI，但你可以使用 Windows PowerShell 或其他工具在本地或远程完全管理服务器。你可以在以后切换到其他安装选项。请参阅“Windows Server 安装选项”。"
)

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Server Core" if "%SourceEdition%" equ "ServerStandard" if "%TargetEdition%" equ "ServerDatacenter" (
	set "Flag=ServerDataCenterCore"
	set "Edition=ServerDatacenter"
	set "Name=Windows Server 2016 SERVERDATACENTERCORE"
	set "Description=Windows Server 2016 SERVERDATACENTERCORE"
	set "DisplayName=Windows Server 2016 Datacenter"
	set "DisplayDescription=此选项^(推荐^)通过仅安装运行大多数服务器角色和应用程序所需的内容来减少管理和服务。它不包含 GUI，但你可以使用 Windows PowerShell 或其他工具在本地或远程完全管理服务器。有关详细信息，请参阅“Windows Server 安装选项”。"
)

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Server" if "%SourceEdition%" equ "ServerSolution" if "%TargetEdition%" equ "ServerStandard" (
	set "Flag=ServerStandard"
	set "Edition=ServerStandard"
	set "Name=Windows Server 2016 SERVERSTANDARD"
	set "Description=Windows Server 2016 SERVERSTANDARD"
	set "DisplayName=Windows Server 2016 Standard ^(桌面体验^)"
	set "DisplayDescription=当需要 GUI 时, 此选项非常有用——例如, 为无法在服务器核心安装上运行的应用程序提供向后兼容性。支持所有服务器角色和功能。有关详细信息, 请参阅“Windows Server 安装选项”。"
)

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "14393" if "%ImageInstallationType%" equ "Server" if "%SourceEdition%" equ "ServerStandard" if "%TargetEdition%" equ "ServerDatacenter" (
	set "Flag=ServerDataCenter"
	set "Edition=ServerDatacenter"
	set "Name=Windows Server 2016 SERVERDATACENTER"
	set "Description=Windows Server 2016 SERVERDATACENTER"
	set "DisplayName=Windows Server 2016 Datacenter ^(桌面体验^)"
	set "DisplayDescription=当需要 GUI 时, 此选项非常有用——例如, 为无法在服务器核心安装上运行的应用程序提供向后兼容性。支持所有服务器角色和功能。有关详细信息, 请参阅“Windows Server 安装选项”。"
)

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Server" if "%SourceEdition%" equ "ServerSolution" if "%TargetEdition%" equ "ServerStandard" (
	set "Flag=ServerStandard"
	set "Edition=ServerStandard"
	set "Name=Windows Server 2019 SERVERSTANDARD"
	set "Description=Windows Server 2019 SERVERSTANDARD"
	set "DisplayName=Windows Server 2019 Standard ^(桌面体验^)"
	set "DisplayDescription=此选项将安装完整的 Windows 图形环境, 从而消耗额外的驱动器空间。如果你想要使用 Windows 桌面或拥有需要它的应用, 它可能会很有用。"
)

if "%SelectedSourceOS%" equ "w10" if "%ImageBuild%" equ "17763" if "%ImageInstallationType%" equ "Server" if "%SourceEdition%" equ "ServerStandard" if "%TargetEdition%" equ "ServerDatacenter" (
	set "Flag=ServerDataCenter"
	set "Edition=ServerDatacenter"
	set "Name=Windows Server 2019 SERVERDATACENTER"
	set "Description=Windows Server 2019 SERVERDATACENTER"
	set "DisplayName=Windows Server 2019 Datacenter ^(桌面体验^)"
	set "DisplayDescription=此选项将安装完整的 Windows 图形环境, 从而消耗额外的驱动器空间。如果你想要使用 Windows 桌面或拥有需要它的应用, 它可能会很有用。"
)
:: 设置映像标识、名称和描述以反映目标版本
echo.正在设置映像 [显示名称] 为“%DisplayName%”……
echo.正在设置映像 [显示说明] 为“%DisplayDescription%”……
echo.正在设置映像 [标识] 为“%Flag%”……
echo.正在设置映像 [版本] 为“%Edition%”……
echo.
%WimLibImagex% info "%InstallWim%" %ImageIndexNo% "%Name%" "%Description%" --image-property DISPLAYNAME="%DisplayName%" --image-property DISPLAYDESCRIPTION="%DisplayDescription%" --image-property FLAGS="%Flag%" >nul
echo.-------------------------------------------------------------------------------
echo.####正在复制 EI.CFG 配置文件到 ^<DVD\sources^> 文件夹############################
echo.-------------------------------------------------------------------------------
echo.
echo.正在复制“%TargetEdition%”的版本 EI.CFG 文件到 ^<DVD\sources^> 文件夹……
if exist "%DVD%\sources\EI.CFG" del /f /q "%DVD%\sources\EI.CFG" >nul
(
	echo.[EditionID]
	echo.%TargetEdition%
	echo.
	echo.[Channel]
	echo.Retail
	echo.
	echo.[VL]
	echo.0
)>"%DVD%\sources\EI.CFG"
echo.
echo.-------------------------------------------------------------------------------
echo.####升级源 WIM 映像版本已完成##################################################
echo.-------------------------------------------------------------------------------
:Stop
echo.
echo.===============================================================================
echo.
pause

set SourceEdition=
set TargetEdition=
set Flag=
set Edition=
set Name=
set Description=
set DisplayName=
set DisplayDescription=

endlocal

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 捕获驱动器或文件夹为 WIM 映像模块
::-------------------------------------------------------------------------------------------
:WIMCapture

setlocal

set SourceDriveFolder=
set TargetWimImageFileName=
set TargetWimImageName=
set TargetWimImageDescription=
set TargetWimImageEditionFlag=
set BootFlag=

cls
echo.===============================================================================
echo.                MSMG 工具箱 - 捕获驱动器或文件夹为 WIM 映像
echo.===============================================================================
echo.
echo.-------------------------------------------------------------------------------
echo.####正在开始捕获驱动器或文件夹为 WIM 映像######################################
echo.-------------------------------------------------------------------------------
echo.
:: 获取源驱动器或文件夹路径以捕获为 WIM 映像
set /p SourceDriveFolder=请输入有效的源驱动器或文件夹路径 ：
echo.
:: 获取目标 WIM 映像文件名称
set /p TargetWimImageFileName=请输入目标 WIM 映像文件名称 ：
echo.
:: 获取目标 WIM 映像名称
set /p TargetWimImageName=请输入目标 WIM 映像名称 ：
echo.
:: 获取目标 WIM 映像描述
set /p TargetWimImageDescription=请输入目标 WIM 映像描述 ：
echo.
:: 获取目标 WIM 映像描述
set /p TargetWimImageEditionFlag=请输入目标 WIM 映像版本 ：
echo.
:: 获取可引导标识状态
choice /C:YN /N /M "使目标 WIM 映像可引导 ？ [是‘Y’/否‘N’] ："
if errorlevel 2 set BootFlag=No
if not errorlevel 2 set BootFlag=Yes
echo.
echo.-------------------------------------------------------------------------------
echo.####正在捕获驱动器或文件夹为 WIM 映像##########################################
echo.-------------------------------------------------------------------------------
call :CaptureImage "%DVD%\sources\%TargetWimImageFileName%", "%SourceDriveFolder%", %TargetWimImageName%, %TargetWimImageDescription%, %BootFlag%
echo.-------------------------------------------------------------------------------
echo.####正在设置目标 WIM 映像标识、名称和描述######################################
echo.-------------------------------------------------------------------------------
echo.
:: 设置 WIM 映像标识、名称和描述以反映目标版本
echo.正在设置 WIM 映像 [名称] 为“%TargetWimImageName%”……
echo.
echo.正在设置 WIM 映像 [描述] 为“%TargetWimImageDescription%”……
echo.
echo.正在设置 WIM 映像 [标识] 为“%TargetWimImageEditionFlag%”……
%Imagex% /Flags "%TargetWimImageEditionFlag%" /Info "%DVD%\sources\%TargetWimImageFileName%" 1 %TargetWimImageName% %TargetWimImageDescription% >nul
echo.
echo.-------------------------------------------------------------------------------
echo.####捕获驱动器或文件夹为 WIM 映像已完成########################################
echo.-------------------------------------------------------------------------------
:Stop
echo.
echo.===============================================================================
echo.
pause

set SourceDriveFolder=
set TargetWimImageFileName=
set TargetWimImageName=
set TargetWimImageDescription=
set TargetWimImageEditionFlag=
set BootFlag=

endlocal

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 应用 WIM 映像索引到驱动器或文件夹模块
::-------------------------------------------------------------------------------------------
:WIMApply

setlocal

set TargetDriveFolder=

cls
echo.===============================================================================
echo.               MSMG 工具箱 - 应用 WIM 映像索引到驱动器或文件夹
echo.===============================================================================
echo.
:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请复制 Windows 安装程序安装映像到相应的文件夹……
	goto :Stop
)
echo.-------------------------------------------------------------------------------
echo.####正在开始应用 WIM 映像索引到驱动器或文件夹##################################
echo.-------------------------------------------------------------------------------

:: 显示映像信息
call :ShowImageInfo

:: 获取映像索引编号以导出
if "%ImageCount%" equ "1" ( 
	set /p ImageIndexNo=请输入 WIM 映像索引号 ：
) else set /p ImageIndexNo=请输入 WIM 映像索引号的 [范围 ： 1-!ImageCount!] ：

if "%ImageIndexNo%" lss "1" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMApply
)

if "%ImageIndexNo%" gtr %ImageCount% (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMApply
)

:: 获取目标驱动器或文件夹路径以应用 WIM 映像索引
echo.
set /p TargetDriveFolder=请输入目标驱动器或文件夹路径 ：
echo.
echo.-------------------------------------------------------------------------------
echo.####正在应用 WIM 映像索引到驱动器或文件夹######################################
echo.-------------------------------------------------------------------------------
echo.
call :ApplyImage "%InstallWim%", %ImageIndexNo%, %TargetDriveFolder%
echo.-------------------------------------------------------------------------------
echo.####应用 WIM 映像索引到驱动器或文件夹已完成####################################
echo.-------------------------------------------------------------------------------
:Stop
echo.
echo.===============================================================================
echo.
pause

set TargetDriveFolder=

endlocal

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 清理 WIM 映像索引模块
::-------------------------------------------------------------------------------------------
:WIMCleanUp

setlocal

set CleanupOption=

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 清理 WIM 映像索引
echo.===============================================================================
echo.
:: 检查 Windows 源安装映像文件是否存在
if not exist "%InstallWim%" (
	echo.无法找到 Windows 安装程序安装映像 ^<DVD\Sources\install.wim^> 文件……
	echo.
	echo.请复制 Windows 安装程序安装映像到相应的文件夹……
	goto :Stop
)
echo.  [1]  清理映像
echo.
echo.  [2]  使用 CheckHealth 清理映像
echo.
echo.  [3]  使用 ScanHealth 清理映像
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:123X /N /M "请输入你的选项 ："
if errorlevel 4 goto :ToolsMenu
if errorlevel 3 set "CleanupOption=ScanHealth"
if errorlevel 2 set "CleanupOption=CheckHealth"
if errorlevel 1 set "CleanupOption=CleanupImage"

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 清理 WIM 映像索引
echo.===============================================================================
echo.
echo.-------------------------------------------------------------------------------
if "%CleanupOption%" equ "CleanupImage" echo.####正在开始对源 WIM 映像文件进行清理##########################################
if "%CleanupOption%" equ "CheckHealth" echo.####正在开始使用 CheckHealth 对源 WIM 映像文件进行清理#########################
if "%CleanupOption%" equ "ScanHealth" echo.####正在开始使用 CheckHealth 对源 WIM 映像文件进行清理#########################
echo.-------------------------------------------------------------------------------

:: 显示映像信息
call :ShowImageInfo

:: 获取映像索引编号以清理
if "%ImageCount%" equ "1" ( 
	set /p ImageIndexNo=请输入 WIM 映像索引号 ：
) else set /p ImageIndexNo=请输入 WIM 映像索引号的 [范围 ： 1-!ImageCount!] ：

if "%ImageIndexNo%" lss "1" (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMApply
)

if "%ImageIndexNo%" gtr %ImageCount% (
	echo.
	echo.输入的索引编号无效，有效范围为 [1-%ImageCount%]
	echo.
	echo.请按 Enter 键再试一次……
	pause >nul

	goto :WIMApply
)

:: 获取所选择的映像索引信息
call :GetImageIndexInfo "%InstallWim%", %ImageIndexNo% >nul

:: 设置所选择的源操作系统
if "%ImageVersion%" equ "6.1.7601" set "SelectedSourceOS=w7"
if "%ImageVersion%" equ "6.3.9600" set "SelectedSourceOS=w81"
if "%ImageVersion:~0,-6%" equ "10.0" set "SelectedSourceOS=w10"

echo.
echo.-------------------------------------------------------------------------------
if "%CleanupOption%" equ "CleanupImage" echo.####清理源 WIM 映像############################################################
if "%CleanupOption%" equ "CheckHealth" echo.####使用 CheckHealth 清理源 WIM 映像###########################################
if "%CleanupOption%" equ "ScanHealth" echo.####使用 ScanHealth 清理源 WIM 映像############################################
echo.-------------------------------------------------------------------------------
echo.
echo.-------------------------------------------------------------------------------
echo.正在将 [Install.wim，索引 ：%ImageIndexNo%] 的 WIM 映像安装在 ^<\Mount\Install^> 中……
echo.-------------------------------------------------------------------------------
call :MountImage "%InstallWim%", %ImageIndexNo%, "%InstallMount%"
echo.-------------------------------------------------------------------------------
echo.正在执行对 [Install.wim，索引 ：%ImageIndexNo%] 的 WIM 映像清理……
echo.-------------------------------------------------------------------------------
if "%CleanupOption%" equ "CleanupImage" (
	if "%SelectedSourceOS%" equ "w7" call :CleanupImage "%InstallMount%", "SPSupersededHideSP"
	if "%SelectedSourceOS%" neq "w7" call :CleanupImage "%InstallMount%", "ComponentCleanupResetBase"
) else (
	call :CleanupImage "%InstallMount%", "ComponentCleanup", "%CleanupOption%"
)
echo.-------------------------------------------------------------------------------
echo.正在应用更改并卸载源 [Install.wim，索引 ：%ImageIndexNo%] WIM 映像……
echo.-------------------------------------------------------------------------------
call :UnMountImage "%InstallMount%", "Commit"
echo.-------------------------------------------------------------------------------
if "%CleanupOption%" equ "CleanupImage" echo.####源 WIM 映像清理已完成######################################################
if "%CleanupOption%" equ "CheckHealth" echo.####使用 CheckHealth 对源 WIM 映像的清理已完成#################################
if "%CleanupOption%" equ "ScanHealth" echo.####使用 ScanHealth 对源 WIM 映像的清理已完成##################################
echo.-------------------------------------------------------------------------------

:Stop
echo.
echo.===============================================================================
echo.
pause

set CleanupOption=

endlocal

goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 显示 MSMG 工具箱调试信息模块
::-------------------------------------------------------------------------------------------
:Debug

cls
echo.===============================================================================
echo.                           MSMG 工具箱 - 调试信息
echo.===============================================================================
echo. HostArchitecture=%HostArchitecture%
echo. SelectedSourceOS=%SelectedSourceOS%
echo. IsSourceSelected=%IsSourceSelected%
echo. IsDialogsEnabled=%IsDialogsEnabled%
echo. IsLogsEnabled=%IsLogsEnabled%
echo.
echo. ImageIndexNo=%ImageIndexNo%
if "%ImageIndexNo%" neq "*" (
	echo. ImageName=%ImageName%
	echo. ImageDescription=%ImageDescription%
)
echo. ImageArchitecture=%ImageArchitecture%
echo. ImageBuild=%ImageBuild%
echo. ImageVersion=%ImageVersion%
echo. ImageServicePackBuild=%ImageServicePackBuild%
echo. ImageServicePackLevel=%ImageServicePackLevel%
if "%ImageIndexNo%" neq "*" (
	echo. ImageEdition=%ImageEdition%
	echo. ImageFlag=%ImageFlag%
	echo. ImageInstallationType=%ImageInstallationType%
)
echo. ImageDefaultLanguage=%ImageDefaultLanguage%
echo. ImageCount=%ImageCount%
echo.===============================================================================
pause

:: 返回到主菜单
goto :MainMenu
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: MSMG 工具箱 - 选项菜单
::-------------------------------------------------------------------------------------------
:Options

cls
echo.===============================================================================
echo.                          MSMG 工具箱 - Options Menu
echo.===============================================================================
echo.
echo.  [1]   配置工具箱颜色设置
echo.
if "%IsDialogsEnabled%" equ "No" echo.  [2]   启用工具箱信息/警告对话框
if "%IsDialogsEnabled%" equ "Yes" echo.  [2]   禁用工具箱信息/警告对话框
echo.
if "%IsLogsEnabled%" equ "No" echo.  [3]   启用工具箱日志生成
if "%IsLogsEnabled%" equ "Yes" echo.  [3]   禁用工具箱日志生成
echo.
if "%IsImageRegistryLoaded%" equ "No" echo.  [4]   加载映像注册表
if "%IsImageRegistryLoaded%" equ "Yes" echo.  [4]   卸载映像注册表
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.  [X]   返回
echo.
echo.===============================================================================
echo.
choice /C:1234X /N /M "请输入你的选项 ："
if errorlevel 5 goto :ToolsMenu
if errorlevel 4 (
	if "%IsImageRegistryLoaded%" equ "No" (
		cls
		echo.===============================================================================
		echo.                          MSMG 工具箱 - 映像注册表
		echo.===============================================================================
		echo.
		:: 检查源操作系统是否已选择
		if "%IsSourceSelected%" equ "No" (
			echo.尚未选择源操作系统，请从“源文件”菜单中选择……
			echo.
			echo.===============================================================================
			echo.
			pause
			goto :MainMenu
		)

		:: 检查多重索引维护模式是否已启用
		if "%ImageIndexNo%" equ "*" (
			echo.当多重索引维护模式已启用时，此功能不可用……
			echo.
			echo.请使用单一的索引重新选择源文件……
			goto :Stop
		)
		echo.正在加载映像注册表……
		call :MountImageRegistry "%InstallMount%"
		set "IsImageRegistryLoaded=Yes"
		echo.
		echo.[HKEY_LOCAL_MACHINE\TK_SOFTWARE]         -^> [HKEY_LOCAL_MACHINE\SOFTWARE]
		echo.[HKEY_LOCAL_MACHINE\TK_SOFTWARE\Classes] -^> [HKEY_CLASSES_ROOT]
		echo.[HKEY_LOCAL_MACHINE\TK_SYSTEM]           -^> [HKEY_LOCAL_MACHINE\SYSTEM]
		echo.[HKEY_LOCAL_MACHINE\TK_NTUSER]           -^> [HKEY_CURRENT_USER]
		echo.[HKEY_LOCAL_MACHINE\TK_DEFAULT]          -^> [HKEY_USERS\.Default]
		echo.
		echo.加载映像注册表完成……
		echo.
		echo.===============================================================================
		echo.
		pause
	)
	if "%IsImageRegistryLoaded%" equ "Yes" (
		cls
		echo.===============================================================================
		echo.                          MSMG 工具箱 - 映像注册表
		echo.===============================================================================
		echo.
		echo.正在卸载映像注册表……
		call :UnMountImageRegistry
		set "IsImageRegistryLoaded=No"
		echo.
		echo.卸载映像注册表完成……
		echo.
		echo.===============================================================================
		echo.
		pause
	)
	goto :Toolsmenu
)
if errorlevel 3 (
	if "%IsLogsEnabled%" equ "No" set "IsLogsEnabled=Yes"
	if "%IsLogsEnabled%" equ "Yes" set "IsLogsEnabled=No"
	goto :Toolsmenu
)
if errorlevel 2 (
	if "%IsDialogsEnabled%" equ "No" set "IsDialogsEnabled=Yes"
	if "%IsDialogsEnabled%" equ "Yes" set "IsDialogsEnabled=No"
	goto :Toolsmenu
)
if errorlevel 1 goto :SetTkColor

::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 配置工具箱颜色设定模块
::-------------------------------------------------------------------------------------------
:SetTkColor

cls
echo.===============================================================================
echo.                      MSMG 工具箱 - 配置工具箱配色设置
echo.===============================================================================
echo. 可用于配置的背景色 / 前景色列表 ：
echo.
echo.  [1]  黑色   - 白色                [F]  水蓝色 - 蓝色
echo.  [2]  黑色   - 浅绿色              [G]  水蓝色 - 亮蓝色
echo.  [3]  黑色   - 淡蓝色              [H]  水蓝色 - 亮黄色
echo.  [4]  黑色   - 浅红色              [I]  红色   - 亮绿色
echo.  [5]  黑色   - 浅黄色              [J]  红色   - 淡蓝色
echo.  [6]  黑色   - 亮白色              [K]  红色   - 亮黄色
echo.  [7]  蓝色   - 白色                [L]  红色   - 亮白色
echo.  [8]  蓝色   - 浅绿色              [M]  浅蓝色 - 白色
echo.  [9]  蓝色   - 淡蓝色              [N]  浅蓝色 - 亮绿色
echo.  [A]  蓝色   - 亮红色              [O]  浅蓝色 - 淡蓝色
echo.  [B]  蓝色   - 浅紫色              [P]  浅蓝色 - 亮黄色
echo.  [C]  蓝色   - 浅黄色              [Q]  浅蓝色 - 亮白色
echo.  [D]  蓝色   - 亮白色              [R]  亮白色 - 黑色
echo.  [E]  水蓝色 - 黑色                [S]  亮白色 - 蓝色
echo.
echo.  [X]  返回
echo.===============================================================================
echo.
choice /C:123456789ABCDEFGHIJKLMNoPQRSX /N /M "请输入你的选项 ："
if errorlevel 29  goto :Options
if errorlevel 28  color F1 & goto :MainMenu
if errorlevel 27  color F0 & goto :MainMenu
if errorlevel 26  color 9F & goto :MainMenu
if errorlevel 25  color 9E & goto :MainMenu
if errorlevel 24  color 9B & goto :MainMenu
if errorlevel 23  color 9A & goto :MainMenu
if errorlevel 22  color 97 & goto :MainMenu
if errorlevel 21  color 4F & goto :MainMenu
if errorlevel 20  color 4E & goto :MainMenu
if errorlevel 19  color 4B & goto :MainMenu
if errorlevel 18  color 4A & goto :MainMenu
if errorlevel 17  color 3E & goto :MainMenu
if errorlevel 16  color 39 & goto :MainMenu
if errorlevel 15  color 31 & goto :MainMenu
if errorlevel 14  color 30 & goto :MainMenu
if errorlevel 13  color 1F & goto :MainMenu
if errorlevel 12  color 1E & goto :MainMenu
if errorlevel 11  color 1D & goto :MainMenu
if errorlevel 10  color 1C & goto :MainMenu
if errorlevel 9   color 1B & goto :MainMenu
if errorlevel 8   color 1A & goto :MainMenu
if errorlevel 7   color 17 & goto :MainMenu
if errorlevel 6   color 0F & goto :MainMenu
if errorlevel 5   color 0E & goto :MainMenu
if errorlevel 4   color 0C & goto :MainMenu
if errorlevel 3   color 0B & goto :MainMenu
if errorlevel 2   color 0A & goto :MainMenu
if errorlevel 1   color 07 & goto :MainMenu
::-------------------------------------------------------------------------------------------

:: ############################################################################################
:: MSMG 工具箱 DISM 模块
:: ############################################################################################

::-------------------------------------------------------------------------------------------
:: 获取映像索引总数模块
:: 输入参数 [ %~1 ：映像文件名称 ]
::-------------------------------------------------------------------------------------------
:GetImageCount

:: 查找映像中存在的索引总数。
for /f "tokens=2 delims=: " %%a in ('%DISM% /Get-ImageInfo /ImageFile:%~1 ^| findstr /i Index') do (set ImageCount=%%a)

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 显示映像信息模块
::-------------------------------------------------------------------------------------------
:ShowImageInfo

set "ImageInfo=%Temp%\ImageInfo.txt"

call :RemoveFile %ImageInfo%

:: 获取映像中存在的索引总数。
call :GetImageCount "%InstallWim%"

echo.
echo.正在读取映像信息……
echo.
:: 列出映像中的所有索引。
echo.===============================================================================>>%ImageInfo%
echo.^|索引    ^| 体系结构    ^| 名称>>%ImageInfo%
echo.===============================================================================>>%ImageInfo%
for /f "tokens=2 delims=: " %%a in ('%DISM% /Get-WimInfo /WimFile:%InstallWim% ^| findstr /i Index') do (
	for /f "tokens=2 delims=: " %%b in ('%DISM% /Get-WimInfo /WimFile:%InstallWim% /Index:%%a ^| findstr /i Architecture') do (
		for /f "tokens=2 delims=:" %%c in ('%DISM% /Get-WimInfo /WimFile:%InstallWim% /Index:%%a ^| findstr /i Name') do (
			if "%%b" neq "arm64" (
				if %%a leq 9 echo.^|  %%a     ^| %%b         ^| %%c>>%ImageInfo%
				if %%a gtr 9 if %%a lss 99 echo.^|  %%a     ^| %%b        ^| %%c>>%ImageInfo%
				if %%a gtr 99 echo.^|  %%a     ^| %%b       ^| %%c>>%ImageInfo%
			)			
			if "%%b" equ "arm64" (
				if %%a leq 9 echo.^|  %%a     ^| %%b         ^| %%c>>%ImageInfo%
				if %%a gtr 9 if %%a lss 99 echo.^|  %%a     ^| %%b        ^| %%c>>%ImageInfo%
				if %%a gtr 99 echo.^|  %%a     ^| %%b       ^| %%c>>%ImageInfo%
			)
		)
	)
)

type %ImageInfo%
call :RemoveFile %ImageInfo%

echo.===============================================================================
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 获取映像索引编号用于服务模块
:: 输入参数 [ %~1 ：映像文件名称 ]
::-------------------------------------------------------------------------------------------
:GetImageIndexNo

:: 显示可用映像索引列表。
call :ShowImageInfo

if "%ImageCount%" equ "1" ( 
	set /p ImageIndexNo=请输入 WIM 映像索引编号 # ：
) else set /p ImageIndexNo=请输入 WIM 映像索引编号的 # [范围 ：1-%ImageCount%，* - 全部] ：

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 获取映像索引版本模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：映像索引编号 ]
::-------------------------------------------------------------------------------------------
:GetImageArchitecture

for /f "tokens=2 delims=: " %%a in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Architecture') do (set ImageArchitecture=%%a)

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 获取映像索引信息模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：映像索引编号 ]
::-------------------------------------------------------------------------------------------
:GetImageEdition

for /f "tokens=2 delims=: " %%f in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Edition') do (set ImageEdition=%%f)

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: Function to get Image Index Information
:: 输入参数 [%~1 ：映像文件名称、%~2 ：映像索引编号]
::-------------------------------------------------------------------------------------------
:GetImageIndexInfo

for /f "tokens=2 delims=:" %%a in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Name') do (set ImageName=%%a)
for /f "tokens=2 delims=:" %%b in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Description') do (set ImageDescription=%%b)
for /f "tokens=2 delims=: " %%c in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Architecture') do (set ImageArchitecture=%%c)
for /f "tokens=2 delims=: " %%d in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Version') do (set ImageVersion=%%d)
for /f "tokens=2 delims=:" %%e in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| find "ServicePack Build"') do ( set ImageServicePackBuild=%%e)
for /f "tokens=2 delims=:" %%f in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| find "ServicePack Level"') do ( set ImageServicePackLevel=%%f)
for /f "tokens=2 delims=: " %%g in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Edition') do (set ImageEdition=%%g)
for /f "tokens=2 delims=:<> " %%h in ('%Imagex% /info "%~1" %~2 ^| findstr /i Flag') do (set ImageFlag=%%h)
for /f "tokens=2 delims=:" %%i in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Installation') do (set ImageInstallationType=%%i)
for /f "tokens=* delims=" %%j in ('%DISM% /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Default') do ( set ImageDefaultLanguage=%%j)

set "ImageName=%ImageName:~1%"
set "ImageDescription=%ImageDescription:~1%"
if "%ImageVersion:~0,-6%" neq "10.0" set "ImageBuild=%ImageVersion:~4,4%"
if "%ImageVersion:~0,-6%" equ "10.0" set "ImageBuild=%ImageVersion:~5,5%"
set "ImageServicePackBuild=%ImageServicePackBuild:~1%"
set "ImageServicePackLevel=%ImageServicePackLevel:~1%"
set "ImageInstallationType=%ImageInstallationType:~1%"
set "ImageDefaultLanguage=%ImageDefaultLanguage:~1,-10%"

if "%ImageFlag%" equ "" set "ImageFlag=%ImageEdition%"

if "%ImageInstallationType:~,6%" equ "Server" set "ImageDescription=%ImageDescription:(=[%"
if "%ImageInstallationType:~,6%" equ "Server" set "ImageDescription=%ImageDescription:)=]%"

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 安装映像模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：映像索引编号、%~3 ：映像安装文件夹 ]
::-------------------------------------------------------------------------------------------
:MountImage

%DISM% /Mount-Image /ImageFile:%~1 /Index:%~2 /MountDir:%~3
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 卸载已安装映像模块
:: 输入参数 [ %~1 ：映像安装文件夹、%~2 ：映像提交/丢弃选项 ]
::-------------------------------------------------------------------------------------------
:UnMountImage

%DISM% /Unmount-Image /MountDir:%~1 /%~2
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 从映像中删除选定映像索引模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：映像索引编号 ]
::-------------------------------------------------------------------------------------------
:DeleteImage

%DISM% /Delete-Image /ImageFile:%~1 /Index:%~2
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 重命名选定映像索引信息模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：映像索引编号、%~3 ：映像名称、%~4 ：映像描述 ]
::-------------------------------------------------------------------------------------------
:RenameImage

%Imagex% /Info %~1 %~2 "%~3" "%~4"

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 拆分映像模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：映像拆分文件名称、%~3 ：映像拆分大小，单位 MB ]
::-------------------------------------------------------------------------------------------
:SplitImage

%DISM% /Split-Image /ImageFile:%~1 /SWMFile:%~2 /FileSize:%~3
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 合并已拆分映像模块
:: 输入参数 [ %~1 ：无扩展名的映像拆分文件名、%~2 ：映像文件名称 ]
::-------------------------------------------------------------------------------------------
:MergeImage

%Imagex% /ref %~1*.swm /Check /Export %~1.swm * %~2

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 应用映像驱动器或文件夹模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：映像索引编号、%~3 ：映像应用驱动器或文件夹名称 ]
::-------------------------------------------------------------------------------------------
:ApplyImage

%DISM% /Apply-Image /ImageFile:%~1 /Index:%~2 /ApplyDir:%~3\ /CheckIntegrity /Verify
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 捕获驱动器或文件夹为映像模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：捕获驱动器或文件夹名称、
::            %~3 ：索引名称、%~4 ：索引描述、%~5 ：可启动或未配置 ]
::-------------------------------------------------------------------------------------------
:CaptureImage

if "%~5" equ "Yes" %DISM% /Capture-Image /Imagefile:%~1 /CaptureDir:%~2 /Name:"%~3" /Description:"%~4" /ConfigFile:%WimConfigFile% /Bootable /Compress:Max /CheckIntegrity /Verify 
if "%~5" equ "No" %DISM% /Capture-Image /Imagefile:%~1 /CaptureDir:%~2 /Name:"%~3" /Description:"%~4" /ConfigFile:%WimConfigFile% /Compress:Max /CheckIntegrity /Verify 
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 追加另一个映像到映像模块
:: 输入参数 [ %~1 ：映像文件名称、%~2 ：捕获驱动器或文件夹名称、
::            %~3 ：索引名称、%~4 ：索引描述、%~5 ：可启动或未配置 ]
::-------------------------------------------------------------------------------------------
:AppendImage

if "%~5" equ "Yes" %DISM% /Append-Image /Imagefile:%~1 /CaptureDir:%~2 /Name:"%~3" /Description:"%~4" /ConfigFile:%WimConfigFile% /Bootable /CheckIntegrity /Verify 
if "%~5" equ "No" %DISM% /Append-Image /Imagefile:%~1 /CaptureDir:%~2 /Name:"%~3" /Description:"%~4" /ConfigFile:%WimConfigFile% /CheckIntegrity /Verify 
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 使用最大/恢复压缩导出选定映像索引模块
:: 输入参数 [ %~1 ：源映像文件名称、%~2 ：源映像索引编号、
::            %~3 ：目标映像文件名称、%~4 ：映像格式、%~5 ：可启动或未配置 ]
::-------------------------------------------------------------------------------------------
:ExportImageIndex

if "%~4" equ "WIM" if "%~5" equ "Yes" %DISM% /Export-Image /SourceImageFile:%~1 /SourceIndex:%~2 /DestinationImageFile:%~3 /CheckIntegrity /Compress:Max /Bootable
if "%~4" equ "WIM" if "%~5" equ "No" %DISM% /Export-Image /SourceImageFile:%~1 /SourceIndex:%~2 /DestinationImageFile:%~3 /CheckIntegrity /Compress:Max
if "%~4" equ "ESD" if "%~5" equ "Yes" %DISM% /Export-Image /SourceImageFile:%~1 /SourceIndex:%~2 /DestinationImageFile:%~3 /CheckIntegrity /Compress:Recovery /Bootable
if "%~4" equ "ESD" if "%~5" equ "No" %DISM% /Export-Image /SourceImageFile:%~1 /SourceIndex:%~2 /DestinationImageFile:%~3 /CheckIntegrity /Compress:Recovery
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 使用最大/恢复压缩导出所有映像索引模块
:: 输入参数 [ %~1 ：源映像文件名称、%~2 ：目标映像文件名称、%~3 ：映像格式、%~4 ：可启动或未配置 ]
::-------------------------------------------------------------------------------------------
:ExportImage

if "%~3" equ "WIM" if "%~4" equ "Yes" %DISM% /Export-Image /SourceImageFile:%~1 /All /DestinationImageFile:%~2 /CheckIntegrity /Compress:Max /Bootable
if "%~3" equ "WIM" if "%~4" equ "No" %DISM% /Export-Image /SourceImageFile:%~1 /All /DestinationImageFile:%~2 /CheckIntegrity /Compress:Max
if "%~3" equ "ESD" if "%~4" equ "Yes" %DISM% /Export-Image /SourceImageFile:%~1 /All /DestinationImageFile:%~2 /CheckIntegrity /Compress:Recovery /Bootable
if "%~3" equ "ESD" if "%~4" equ "No" %DISM% /Export-Image /SourceImageFile:%~1 /All /DestinationImageFile:%~2 /CheckIntegrity /Compress:Recovery
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 清理映像模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：选项  ]
::-------------------------------------------------------------------------------------------
:CleanupImage

setlocal

set "CleanupOption=%~2"

if "%CleanupOption%" equ "SPSupersededHideSP" (
	%DISM% /Image:%~1 /Cleanup-Image /SPSuperseded /HideSP
)

if "%CleanupOption%" equ "ComponentCleanupResetBase" (
	%DISM% /Image:%~1 /Cleanup-Image /StartComponentCleanup /ResetBase
)

if "%CleanupOption%" equ "CheckHealth" (
	%DISM% /Image:%~1 /Cleanup-Image /CheckHealth
)

if "%CleanupOption%" equ "ScanHealth" (
	%DISM% /Image:%~1 /Cleanup-Image /ScanHealth
)

echo.

endlocal

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 添加驱动包到映像模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：驱动包路径 ]
::-------------------------------------------------------------------------------------------
:AddDriver

%DISM% /Image:%~1 /Add-Driver /Driver:%~2 /ForceUnsigned /Recurse
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 启用映像中的功能模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：功能名称 ]
::-------------------------------------------------------------------------------------------
:EnableFeature

%DISM% /Image:%~1 /Enable-Feature /FeatureName:%~2
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 禁用映像中的功能模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：功能名称 ]
::-------------------------------------------------------------------------------------------
:DisableFeature

%DISM% /Image:%~1 /Disable-Feature /FeatureName:%~2
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 导出映像中存在的软件包列表到文件模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：文件名称 ]
::-------------------------------------------------------------------------------------------
:GetPackages

%DISM% /Get-Packages /Image:%~1 > %Logs%\%~2

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 导出映像中存在的功能列表到文件模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：文件名称 ]
::-------------------------------------------------------------------------------------------
:GetFeatures

%DISM% /Get-Features /Format:Table /Image:%~1 > %Logs%\%~2

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 添加软件包到映像模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：软件包路径 / 软件包名称 ]
::-------------------------------------------------------------------------------------------
:AddPackage

%DISM% /Image:%~1 /Add-Package /PackagePath:%~2
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 从映像中移除软件包模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：软件包路径 / 软件包名称 ]
::-------------------------------------------------------------------------------------------
:RemovePackage

%DISM% /Image:%~1 /Remove-Package /PackageName:%~2
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 添加预装 Appx 软件包模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：应用名称、%~3 ：应用包路径、%~4 ：应用授权路径、%~5 ：应用依赖包程序路径 ]
::-------------------------------------------------------------------------------------------
:AddProvisionedAppxPackage

echo.-------------------------------------------------------------------------------
echo.正在集成 %~2 预装 Appx 软件包……
echo.-------------------------------------------------------------------------------
%DISM% /Image:%~1 /Add-ProvisionedAppxPackage /PackagePath:%~3 /LicensePath:%~4 %~5
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 移除预装 Appx 软件包模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：应用名称、%~3 ：软件包名称 ]
::-------------------------------------------------------------------------------------------
:RemoveProvisionedAppxPackage

setlocal

set PackageName=

echo.-------------------------------------------------------------------------------
echo.正在移除 %~2 预装 Appx 软件包……
echo.-------------------------------------------------------------------------------

:: 获取预装 Appx 软件包列表
for /f "tokens=2 delims=: " %%a in ('%DISM% /Image:%~1 /Get-ProvisionedAppxPackages ^| find /I "PackageName : %~3"') do (set PackageName=%%a)

if "%PackageName%" equ "" (
	echo.
	echo.指定的预装 Appx 软件包已经被移除……
) else (
	:: 移除映像中的预装 Appx 软件包
	%DISM% /Image:%~1 /Remove-ProvisionedAppxPackage /PackageName:%PackageName%
)

echo.

set PackageName=

endlocal

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 从 Windows 映像中移除默认应用关联模块
:: 输入参数 [ %~1 ：映像安装路径 ]
::-------------------------------------------------------------------------------------------
:RemoveDefaultAppAssociations

%DISM% /Image:%~1 /Remove-DefaultAppAssociations

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 将一组默认应用程序关联导入 Windows 映像模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：应用关联 XML 文件名 ]
::-------------------------------------------------------------------------------------------
:ImportDefaultAppAssociations

%DISM% /Image:%~1 /Import-DefaultAppAssociations:%~2

goto :eof
::-------------------------------------------------------------------------------------------

:: ############################################################################################
:: MSMG 工具箱其他模块
:: ############################################################################################

::-------------------------------------------------------------------------------------------
:: 用于从映像中移除已锁定/隐藏的 Windows 程序包模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：软件包描述、%~3 ：软件包名称 ]
::-------------------------------------------------------------------------------------------
:RemoveLockedPackage

setlocal

set PackageName=

echo.-------------------------------------------------------------------------------
echo.正在移除 %~2 软件包……
echo.-------------------------------------------------------------------------------

:: 使锁定/隐藏的 Windows 软件包可见
call :UnHidePackage "%~1"、%~3

:: 获取 Windows 软件包列表
for /f "tokens=2 delims=:" %%a in ('%DISM% /Image:%~1 /Get-Packages ^| find /I "%~3"') do ( set PackageName=%%a )

if "%PackageName%" neq "" (
	if "%SelectedSourceOS%" equ "w7" (
		for /f "tokens=* delims= " %%a in ("%PackageName%") do set PackageName=%%a
		for /l %%a in (1,1,31) do if "!PackageName:~-1!" equ " " set PackageName=!PackageName:~0,-1!
	)
	if "%SelectedSourceOS%" neq "w7" set PackageName=%PackageName:~1,-1%
)

if "%PackageName%" equ "" (
	echo.
	echo.指定的软件包已经被移除……
	echo.
) else (
	:: 从映像移除 Windows 软件包
	%DISM% /Image:%~1 /Remove-Package /PackageName:%PackageName%
	echo.
)

set PackageName=

endlocal

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 使用 ToolKitHelper.exe 从映像中移除 Windows 组件模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：组件描述、%~3 ：组件名称 ]
::-------------------------------------------------------------------------------------------
:RemoveWindowsComponent

setlocal

set ComponentName=

echo.-------------------------------------------------------------------------------
echo.正在移除 %~2 软件包……
echo.-------------------------------------------------------------------------------
%ToolKitHelper% %~1 %~3
echo.

:: 卸载映像注册表（如果已安装/丢弃）
call :UnMountImageRegistry

set ComponentName=

endlocal

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 安装映像注册表模块
:: 输入参数 [ %~1 ：映像安装路径 ]
::-------------------------------------------------------------------------------------------
:MountImageRegistry

:: 安装映像注册表用于离线编辑
reg load HKLM\TK_COMPONENTS "%~1\Windows\System32\config\COMPONENTS" >nul
reg load HKLM\TK_DEFAULT "%~1\Windows\System32\config\default" >nul
reg load HKLM\TK_NTUSER "%~1\Users\Default\ntuser.dat" >nul
reg load HKLM\TK_SOFTWARE "%~1\Windows\System32\config\SOFTWARE" >nul
reg load HKLM\TK_SYSTEM "%~1\Windows\System32\config\SYSTEM" >nul

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 卸载映像注册表模块
:: 输入参数 [ 无 ]
::-------------------------------------------------------------------------------------------
:UnMountImageRegistry

:: 卸载映像注册表
reg unload HKLM\TK_COMPONENTS >nul 2>&1
reg unload HKLM\TK_DRIVERS >nul 2>&1
reg unload HKLM\TK_DEFAULT >nul 2>&1
reg unload HKLM\TK_NTUSER >nul 2>&1
reg unload HKLM\TK_SCHEMA >nul 2>&1
reg unload HKLM\TK_SOFTWARE >nul 2>&1
reg unload HKLM\TK_SYSTEM >nul 2>&1

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 合并注册表设置到映像注册表模块
:: 输入参数 [ %~1 ：要合并的注册表文件名称 ]
::-------------------------------------------------------------------------------------------
:ImportRegistry2Image

:: 合并注册表设置到映像注册表
reg import "%~1"

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 创建文件夹模块
:: 输入参数 [ %~1 ：文件夹名称 ]
::-------------------------------------------------------------------------------------------
:Create文件夹

if not exist "%~1" md "%~1" >nul

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 删除文件模块
:: 输入参数 [ %~1 ：文件名称 ]
::-------------------------------------------------------------------------------------------
:RemoveFile

if exist "%~1" del /f /q "%~1" >nul

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 删除文件夹模块
:: 输入参数 [ %~1 ：文件夹名称 ]
::-------------------------------------------------------------------------------------------
:Remove文件夹

if exist "%~1" rd /q /s "%~1" >nul

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 取消隐藏 Windows 组件软件包模块
:: 输入参数 [ %~1 ：映像安装路径、%~2 ：软件包名称 ]
::-------------------------------------------------------------------------------------------
:UnHidePackage

setlocal

set RegistryKey=

:: 安装映像注册表
call :MountImageRegistry "%~1" >nul

:: 检索软件包注册表项路径
for /f "tokens=* delims=" %%a in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" /f "%~2" ^| find /I "%~2"') do ( set "RegistryKey=%%a" )

:: 使 Windows 组件包可见
reg add "%RegistryKey%" /v Visibility /t REG_DWORD /d 1 /f >nul 2>&1
reg add "%RegistryKey%" /v DefVis /t REG_DWORD /d 2 /f >nul 2>&1
reg delete "%RegistryKey%\Owners" /f >nul 2>&1

:: 卸载映像注册表
call :UnMountImageRegistry

set RegistryKey=

endlocal

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 清理 MSMG 工具箱的临时文件和文件夹
::-------------------------------------------------------------------------------------------
:CleanUp

echo.正在开始清理……
echo.
echo.正在清理映像注册表安装点……
call :UnMountImageRegistry
echo.
echo.正在清理映像安装点……
Dism.exe /English /Quiet /Unmount-Wim /MountDir:"%BootMount%\1" /Discard >nul
Dism.exe /English /Quiet /Unmount-Wim /MountDir:"%BootMount%\2" /Discard >nul

if exist "%WinReMount%\Windows" Dism.exe /English /Unmount-Wim /MountDir:"%WinReMount%" /Discard >nul
if exist "%InstallMount%\Windows" Dism.exe /English /Unmount-Wim /MountDir:"%InstallMount%" /Discard >nul

if not exist "%InstallMount%\Windows" (
	for /L %%i in (1, 1, 25) do (
		if exist "%InstallMount%\%%i\Windows" Dism.exe /English /Unmount-Wim /MountDir:"%InstallMount%\%%i" /Discard >nul
	)
)

Dism.exe /English /Cleanup-Mountpoints >nul
Dism.exe /English /Cleanup-Wim >nul

:: 清理映像安装点文件夹
call :RemoveFolder "%BootMount%"
call :CreateFolder "%BootMount%\1"
call :CreateFolder "%BootMount%\2"
call :RemoveFolder "%InstallMount%"
call :CreateFolder "%InstallMount%"
call :RemoveFolder "%WinReMount%"
call :CreateFolder "%WinReMount%"
echo.

:: 清理日志文件夹
echo.正在清理日志文件……
call :RemoveFolder "%Logs%"
call :CreateFolder "%Logs%"
echo.

:: 清理临时文件、文件夹
echo.正在清理临时文件……
call :RemoveFolder "%Temp%"
call :CreateFolder "%Temp%"

echo.
echo.已完成清理……
echo.

goto :eof
::-------------------------------------------------------------------------------------------

::-------------------------------------------------------------------------------------------
:: 退出 MSMG 工具箱模块
::-------------------------------------------------------------------------------------------
:Quit

cls
echo.===============================================================================
echo. 	                          MSMG 工具箱 - 退出
echo.===============================================================================
echo.
if "%IsSourceSelected%" equ "Yes" (
	echo.源操作系统已被选择，请从“应用”主菜单中选择保存/丢弃……
	echo.
	echo.===============================================================================
	echo.
	pause
	
	goto :Mainmenu
)
echo.正在执行后清理操作，请稍候……
echo.
call :CleanUp
echo.感谢 MDL 的每一位贡献者……
echo.
echo.正在退出 MSMG 工具箱……
echo.
echo.===============================================================================
echo.
pause

:: 恢复 DOS 窗口大小
reg delete "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /f >nul

color 00
endlocal EnableExtensions
endlocal EnableDelayedExpansion

exit