优化代码,延迟功能更新,ISO光盘卷标处理

This commit is contained in:
dragonflylee 2017-11-27 10:27:20 +08:00
parent 5a3a9c67d0
commit 554f979f88
11 changed files with 173 additions and 299 deletions

Binary file not shown.

Binary file not shown.

View File

@ -29,9 +29,9 @@ if exist "%DVD%\sources\ei.cfg" del /f /q "%DVD%\sources\ei.cfg"
)>"%DVD%\sources\ei.cfg"
rem ÅжÏUEFIÒýµ¼
if exist "%UEFIBoot%" (
"%Oscdimg%" -bootdata:2#p0,e,b"%BIOSBoot%"#pEF,e,b"%UEFIBoot%" -o -h -m -u2 -udfver102 "%DVD%" "%ISOFileName%"
"%Oscdimg%" -bootdata:2#p0,e,b"%BIOSBoot%"#pEF,e,b"%UEFIBoot%" -o -h -m -u2 -udfver102 -l"%ISOLabel%" "%DVD%" "%ISOFileName%"
) else (
"%Oscdimg%" -bootdata:1#p0,e,b"%BIOSBoot%" -o -h -m -u2 -udfver102 "%DVD%" "%ISOFileName%"
"%Oscdimg%" -bootdata:1#p0,e,b"%BIOSBoot%" -o -h -m -u2 -udfver102 -l"%ISOLabel%" "%DVD%" "%ISOFileName%"
)
goto :Exit

View File

@ -0,0 +1,29 @@
;遥测服务
Microsoft-OneCore-TroubleShooting-Package
Microsoft-OneCore-TroubleShooting-WOW64-Package
Microsoft-OneCore-AllowTelemetry-Reduced-Default-Package
Microsoft-Windows-ContentDeliveryManager-Package
;Edge浏览器
Microsoft-Windows-Internet-Browser-Package
;帮助支持
Microsoft-Windows-ContactSupport-Package
;混合现实服务
Microsoft-OneCore-Analog-Capture-AppCapture-Stub-Package
Microsoft-OneCore-Analog-PerceptionApi-Stub-Package
Microsoft-Windows-Client-Features-Package-AutoMerged-analog
Microsoft-Windows-Client-Features-WOW64-Package-AutoMerged-analog
Microsoft-Windows-Holographic-Desktop-Analog-Package
Microsoft-Windows-Holographic-Desktop-Merged-Package
Microsoft-Windows-Holographic-Desktop-Merged-WOW64-Package
;快速助手
Microsoft-Windows-QuickAssist-Package
;连接
Microsoft-Windows-Non-LTSB-RegulatedPackages-Package
;离线文件
Microsoft-Windows-OfflineFiles-Package
Microsoft-Windows-OfflineFiles-WOW64-Package
;文件管理器
Microsoft-Windows-DesktopFileExplorer-Package
;OneDrive
Microsoft-Windows-OneDrive-Setup-Package
Microsoft-Windows-OneDrive-Setup-WOW64-Package

View File

@ -1,57 +0,0 @@
;遥测服务
Microsoft-OneCore-TroubleShooting-Package
Microsoft-OneCore-TroubleShooting-WOW64-Package
Microsoft-OneCore-AllowTelemetry-Reduced-Default-Package
Microsoft-Windows-ContentDeliveryManager-Package
;Edge浏览器
Microsoft-Windows-Internet-Browser-Package
;帮助支持
Microsoft-Windows-ContactSupport-Package
;混合现实服务
Microsoft-OneCore-Analog-Capture-AppCapture-Stub-Package
Microsoft-OneCore-Analog-PerceptionApi-Stub-Package
Microsoft-Windows-Client-Features-Package-AutoMerged-analog
Microsoft-Windows-Client-Features-WOW64-Package-AutoMerged-analog
Microsoft-Windows-Holographic-Desktop-Analog-Package
Microsoft-Windows-Holographic-Desktop-Merged-Package
Microsoft-Windows-Holographic-Desktop-Merged-WOW64-Package
;快速助手
Microsoft-Windows-QuickAssist-Package
;连接
Microsoft-Windows-Non-LTSB-RegulatedPackages-Package
;离线文件
Microsoft-Windows-RetailDemo-OfflineContent-Content-Package
Microsoft-Windows-RetailDemo-OfflineContent-Content-zh-CN-Package
Microsoft-Windows-OfflineFiles-Package
Microsoft-Windows-OfflineFiles-WOW64-Package
;文件管理器
Microsoft-Windows-DesktopFileExplorer-Package
;OneDrive
Microsoft-Windows-OneDrive-Setup-Package
Microsoft-Windows-OneDrive-Setup-WOW64-Package
;Hyper-V
Microsoft-Hyper-V-ClientEdition-Package
;Microsoft-Hyper-V-ClientEdition-WOW64-Package
;Microsoft-Hyper-V-ServerEdition-Package
;Microsoft-Hyper-V-ServerEdition-WOW64-Package
HyperV-Guest-DynamicMemory-Package
HyperV-Guest-Heartbeat-Package
HyperV-Guest-IcSvcExt-Package
HyperV-Guest-KMCL-Package
HyperV-Guest-KvpExchange-Package
HyperV-Guest-Networking-Emulated-Package
HyperV-Guest-Networking-Synthetic-Package
HyperV-Guest-Networking-SrIov-Package
HyperV-Guest-RemoteFx-Package
HyperV-Guest-Shutdown-Package
HyperV-Guest-Storage-Filter-Package
HyperV-Guest-Storage-Synthetic-Package
HyperV-Guest-TimeSync-Package
HyperV-Guest-VmBus-Package
HyperV-HvSocket-WOW64-Package
Microsoft-Windows-HyperV-Guest-Package
Microsoft-Windows-HyperV-Guest-WOW64-Package
HyperV-Feature-ApplicationGuard-Package
HyperV-Feature-Containers-Package
HyperV-Host-Compute-Interop-Package
HyperV-Host-Compute-PowerShell-Module-Package

View File

@ -1,48 +0,0 @@
;遥测服务
Microsoft-OneCore-TroubleShooting-Package
Microsoft-OneCore-AllowTelemetry-Reduced-Default-Package
Microsoft-Windows-ContentDeliveryManager-Package
;Edge浏览器
Microsoft-Windows-Internet-Browser-Package
;帮助支持
Microsoft-Windows-ContactSupport-Package
;混合现实服务
Microsoft-OneCore-Analog-Capture-AppCapture-Stub-Package
Microsoft-OneCore-Analog-PerceptionApi-Stub-Package
Microsoft-Windows-Client-Features-Package-AutoMerged-analog
Microsoft-Windows-Holographic-Desktop-Analog-Package
Microsoft-Windows-Holographic-Desktop-Merged-Package
;快速助手
Microsoft-Windows-QuickAssist-Package
;连接
Microsoft-Windows-Non-LTSB-RegulatedPackages-Package
;离线文件
Microsoft-Windows-RetailDemo-OfflineContent-Content-Package
Microsoft-Windows-RetailDemo-OfflineContent-Content-zh-CN-Package
Microsoft-Windows-OfflineFiles-Package
;文件管理器
Microsoft-Windows-DesktopFileExplorer-Package
;OneDrive
Microsoft-Windows-OneDrive-Setup-Package
;Hyper-V
Microsoft-Hyper-V-ClientEdition-Package
HyperV-Guest-DynamicMemory-Package
HyperV-Guest-Heartbeat-Package
HyperV-Guest-IcSvcExt-Package
HyperV-Guest-KMCL-Package
HyperV-Guest-KvpExchange-Package
HyperV-Guest-Networking-Emulated-Package
HyperV-Guest-Networking-Synthetic-Package
HyperV-Guest-Networking-SrIov-Package
HyperV-Guest-RemoteFx-Package
HyperV-Guest-Shutdown-Package
HyperV-Guest-Storage-Filter-Package
HyperV-Guest-Storage-Synthetic-Package
HyperV-Guest-TimeSync-Package
HyperV-Guest-VmBus-Package
HyperV-HvSocket-Package
Microsoft-Windows-HyperV-Guest-Package
HyperV-Feature-ApplicationGuard-Package
HyperV-Feature-Containers-Package
HyperV-Host-Compute-Interop-Package
HyperV-Host-Compute-PowerShell-Module-Package

View File

@ -0,0 +1,20 @@
;遥测服务
Microsoft-Windows-ContentDeliveryManager-Package
;Edge浏览器
Microsoft-Windows-Internet-Browser-Package
;混合现实服务
Microsoft-Windows-Holographic-Desktop-Analog-Package
Microsoft-Windows-Holographic-Desktop-Merged-Package
Microsoft-Windows-Holographic-Desktop-Merged-WOW64-Package
;快速助手
Microsoft-Windows-QuickAssist-Package
;连接
Microsoft-Windows-Non-LTSB-RegulatedPackages-Package
;离线文件
Microsoft-Windows-OfflineFiles-Package
Microsoft-Windows-OfflineFiles-WOW64-Package
;OneDrive
Microsoft-Windows-OneDrive-Setup-Package
Microsoft-Windows-OneDrive-Setup-WOW64-Package
;文件管理器
Microsoft-Windows-DesktopFileExplorer-Package

View File

@ -1,49 +0,0 @@
;遥测服务
Microsoft-Windows-ContentDeliveryManager-Package
;Edge浏览器
Microsoft-Windows-Internet-Browser-Package
;混合现实服务
Microsoft-Windows-Holographic-Desktop-Analog-Package
Microsoft-Windows-Holographic-Desktop-Merged-Package
Microsoft-Windows-Holographic-Desktop-Merged-WOW64-Package
;快速助手
Microsoft-Windows-QuickAssist-Package
;连接
Microsoft-Windows-Non-LTSB-RegulatedPackages-Package
;离线文件
Microsoft-Windows-OfflineFiles-Package
Microsoft-Windows-OfflineFiles-WOW64-Package
;OneDrive
Microsoft-Windows-OneDrive-Setup-Package
Microsoft-Windows-OneDrive-Setup-WOW64-Package
;文件管理器
Microsoft-Windows-DesktopFileExplorer-Package
;Skype视频
Microsoft-Windows-Skype-ORTC-Package
Microsoft-Windows-Skype-ORTC-WOW64-Package
;Hyper-V
Microsoft-Hyper-V-ClientEdition-Package
;Microsoft-Hyper-V-ClientEdition-WOW64-Package
;Microsoft-Hyper-V-ServerEdition-Package
;Microsoft-Hyper-V-ServerEdition-WOW64-Package
HyperV-Guest-DynamicMemory-Package
HyperV-Guest-Heartbeat-Package
HyperV-Guest-IcSvcExt-Package
HyperV-Guest-KMCL-Package
HyperV-Guest-KvpExchange-Package
HyperV-Guest-Networking-Emulated-Package
HyperV-Guest-Networking-Synthetic-Package
HyperV-Guest-Networking-SrIov-Package
HyperV-Guest-RemoteFx-Package
HyperV-Guest-Shutdown-Package
HyperV-Guest-Storage-Filter-Package
HyperV-Guest-Storage-Synthetic-Package
HyperV-Guest-TimeSync-Package
HyperV-Guest-VmBus-Package
HyperV-HvSocket-WOW64-Package
Microsoft-Windows-HyperV-Guest-Package
Microsoft-Windows-HyperV-Guest-WOW64-Package
HyperV-Feature-ApplicationGuard-Package
HyperV-Feature-Containers-Package
HyperV-Host-Compute-Interop-Package
HyperV-Host-Compute-PowerShell-Module-Package

View File

@ -1,41 +0,0 @@
;遥测服务
Microsoft-Windows-ContentDeliveryManager-Package
;Edge浏览器
Microsoft-Windows-Internet-Browser-Package
;混合现实服务
Microsoft-Windows-Holographic-Desktop-Analog-Package
Microsoft-Windows-Holographic-Desktop-Merged-Package
;快速助手
Microsoft-Windows-QuickAssist-Package
;连接
Microsoft-Windows-Non-LTSB-RegulatedPackages-Package
;离线文件
Microsoft-Windows-OfflineFiles-Package
;OneDrive
Microsoft-Windows-OneDrive-Setup-Package
;文件管理器
Microsoft-Windows-DesktopFileExplorer-Package
;Skype视频
Microsoft-Windows-Skype-ORTC-Package
;Hyper-V
Microsoft-Hyper-V-ClientEdition-Package
HyperV-Guest-DynamicMemory-Package
HyperV-Guest-Heartbeat-Package
HyperV-Guest-IcSvcExt-Package
HyperV-Guest-KMCL-Package
HyperV-Guest-KvpExchange-Package
HyperV-Guest-Networking-Emulated-Package
HyperV-Guest-Networking-Synthetic-Package
HyperV-Guest-Networking-SrIov-Package
HyperV-Guest-RemoteFx-Package
HyperV-Guest-Shutdown-Package
HyperV-Guest-Storage-Filter-Package
HyperV-Guest-Storage-Synthetic-Package
HyperV-Guest-TimeSync-Package
HyperV-Guest-VmBus-Package
HyperV-HvSocket-Package
Microsoft-Windows-HyperV-Guest-Package
HyperV-Feature-ApplicationGuard-Package
HyperV-Feature-Containers-Package
HyperV-Host-Compute-Interop-Package
HyperV-Host-Compute-PowerShell-Module-Package

View File

@ -5,11 +5,12 @@ pushd "%~dp0" && Dism 1>nul 2>nul || mshta vbscript:CreateObject("Shell.Applicat
rem 设置变量
color 1F
mode con cols=120
set "Dism=Dism.exe /NoRestart /LogLevel:1"
set "ESDPath=%~1"
if "%ESDPath%" equ "" call :SelectFolder
rem call :ExportISO "E G", "%~dp0install.wim"
for %%i in (x86 x64) do call :MakeRS3 "%ESDPath%", "%~dp0DVD_%%i", "%%i"
for %%i in (X86 X64) do call :ExportRS3 "%ESDPath%", "%~dp0DVD_%%i", "%%i"
goto :Exit
:SelectFolder
@ -20,16 +21,16 @@ goto :eof
rem 导出ISO镜像 [ %~1 : 盘符列表[空格分隔], %~2 : 目标路径 ]
:ExportISO
if exist "%~2" del /q "%~2"
call :RemoveFile "%~2"
for %%i in (%~1) do call :ExportImage "%%i:\sources\install.wim", "%~2"
goto :eof
rem 导出RS2镜像 [ %~1 : 源路径, %~2 : 目标路径, %~3 处理器架构 ]
:MakeRS2
:ExportRS2
if not exist "%~1" echo [%~1] 不存在 && goto :eof
if exist "%~2" rd /s /q "%~2"
set "WimPath=%~dp0install_RS2_%~3_%date:~0,4%%date:~5,2%%date:~8,2%.wim"
if exist "%WimPath%" del /q "%WimPath%"
set "WimPath=%~dp0Win10_RS2_%~3_%date:~0,4%%date:~5,2%%date:~8,2%.wim"
call :RemoveFile "%WimPath%"
call :RemoveFolder "%~2"
rem 导出安装镜像
for %%i in (combinedchina enterprise) do (
for %%j in ("%~1\*.rs2_release_*%%i*_%~3fre_*.esd") do (
@ -37,24 +38,19 @@ for %%i in (combinedchina enterprise) do (
call :ExportImage "%%j", "%WimPath%"
)
)
call "%~dp0WimHelper.cmd" "%WimPath%", "%~2\sources\install.esd"
rem 生成ISO镜像
for /f "tokens=3 delims=." %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%WimPath%" /Index:1 ^| findstr /i Version') do ( set "ImageRevision=%%f" )
for /f "tokens=4" %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%WimPath%" /Index:1 ^| find "ServicePack Level"') do ( set "ImageBuild=%%f" )
for /f "tokens=* delims=" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%WimPath%" /Index:1 ^| findstr /i Default') do ( set "ImageLanguage=%%f" )
call "%~dp0MakeISO.cmd" "%~2" "Win10_%ImageRevision%.%ImageBuild%_RS2_%~3_%ImageLanguage:~1,-10%"
rd /s /q "%~2"
if not exist "%WimPath%" goto :eof
call :MakeISO "%WimPath%", "%~2"
rem 生成二合一镜像
Dism /Export-Image /SourceImageFile:"%WimPath%" /All /DestinationImageFile:"%~dp0cn_windows_10_1703_%ImageRevision%.%ImageBuild%_x86_x64.esd" /Compress:recovery
del /q "%WimPath%"
rem %Dism% /Export-Image /SourceImageFile:"%WimPath%" /All /DestinationImageFile:"%~dp0cn_windows_10_1703_%ImageRevision%.%ImageBuild%_x86_x64.esd" /Compress:recovery
call :RemoveFile "%WimPath%"
goto :eof
rem 导出RS3镜像 [ %~1 : 源路径, %~2 : 目标路径, %~3 处理器架构 ]
:MakeRS3
:ExportRS3
if not exist "%~1" echo [%~1] 不存在 && goto :eof
if exist "%~2" rd /s /q "%~2"
set "WimPath=%~dp0install_RS3_%~3_%date:~0,4%%date:~5,2%%date:~8,2%.wim"
if exist "%WimPath%" del /q "%WimPath%"
call :RemoveFile "%WimPath%"
call :RemoveFolder "%~2"
rem 导出安装镜像
for %%i in (consumer china business) do (
for %%j in ("%~1\*.rs3_release_*%%i*_%~3fre_*.esd") do (
@ -62,26 +58,34 @@ for %%i in (consumer china business) do (
call :ExportImage "%%j", "%WimPath%"
)
)
call "%~dp0WimHelper.cmd" "%WimPath%", "%~2\sources\install.esd"
rem 生成ISO镜像
for /f "tokens=3 delims=." %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%WimPath%" /Index:1 ^| findstr /i Version') do ( set "ImageRevision=%%f" )
for /f "tokens=4" %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%WimPath%" /Index:1 ^| find "ServicePack Level"') do ( set "ImageBuild=%%f" )
for /f "tokens=* delims=" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%WimPath%" /Index:1 ^| findstr /i Default') do ( set "ImageLanguage=%%f" )
call "%~dp0MakeISO.cmd" "%~2" "Win10_%ImageRevision%.%ImageBuild%_RS3_%~3_%ImageLanguage:~1,-10%"
rd /s /q "%~2"
call :MakeISO "%WimPath%", "%~2"
rem 生成二合一镜像
Dism /Export-Image /SourceImageFile:"%WimPath%" /All /DestinationImageFile:"%~dp0cn_windows_10_1709_%ImageRevision%.%ImageBuild%_x86_x64.esd" /Compress:recovery
del /q "%WimPath%"
%Dism% /Export-Image /SourceImageFile:"%WimPath%" /All /DestinationImageFile:"%~dp0cn_windows_10_1709_%ImageRevision%.%ImageBuild%_x86_x64.esd" /Compress:recovery
call :RemoveFile "%WimPath%"
goto :eof
rem 生成ISO [ %~1 : 源路径, %~2 : 目标路径 ]
:MakeISO
call "%~dp0WimHelper.cmd" "%~1"
rem 转换ESD镜像
%Dism% /Export-Image /SourceImageFile:"%~1" /All /DestinationImageFile:"%~2\sources\install.esd" /Compress:recovery
rem 生成ISO镜像
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:1 ^| findstr /i Architecture') do ( set "ImageArch=%%f" )
for /f "tokens=3 delims=." %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:1 ^| findstr /i Version') do ( set "ImageRevision=%%f" )
for /f "tokens=4" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:1 ^| find "ServicePack Level"') do ( set "ImageBuild=%%f" )
for /f "tokens=* delims=" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%~1" /Index:1 ^| findstr /i Default') do ( set "ImageLanguage=%%f" )
call "%~dp0MakeISO.cmd" "%~2" "Win10_%ImageRevision%.%ImageBuild%_%ImageArch%_%ImageLanguage:~1,-10%"
call :RemoveFolder "%~2"
goto :eof
rem 生成DVD镜像目录 [ %~1 : 源路径, %~2 : 目标路径 ]
:ExportDVD
md "%~2"
Dism /Apply-Image /ImageFile:"%~1" /Index:1 /ApplyDir:"%~2"
%Dism% /Apply-Image /ImageFile:"%~1" /Index:1 /ApplyDir:"%~2"
rem 获取版本信息
for /f "tokens=3" %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%~1" /Index:3 ^| findstr /i Version') do ( set "FullVersion=%%f" )
for /f "tokens=3" %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%~1" /Index:3 ^| findstr /i Architecture') do ( set "ImageArch=%%f" )
set "NetFx3Path=%~dp0Pack\NetFx3\%FullVersion%.%ImageArch%"
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:3 ^| findstr /i Version') do ( set "ImageVersion=%%f" )
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:3 ^| findstr /i Architecture') do ( set "ImageArch=%%f" )
set "NetFx3Path=%~dp0Pack\NetFx3\%ImageVersion%.%ImageArch%"
if not exist "%NetFx3Path%" xcopy /I /H /R /Y "%~2\sources\sxs" "%NetFx3Path%" >nul
rem 清理无用文件
del /q "%~2\setup.exe"
@ -95,7 +99,7 @@ for /f "tokens=* delims=" %%f in ('dir /a:-d /b "%~2\boot\fonts" ^| findstr /v "
for /f "tokens=* delims=" %%f in ('dir /a:-d /b "%~2\efi\microsoft\boot" ^| findstr /v "bcd efisys.bin"') do del /q "%~2\efi\microsoft\boot\%%f"
for /f "tokens=* delims=" %%f in ('dir /a:-d /b "%~2\efi\microsoft\boot\fonts" ^| findstr /v "chs wgl4"') do del /q "%~2\efi\microsoft\boot\fonts\%%f"
rem 导出WinPE
Dism /Export-Image /SourceImageFile:"%~1" /SourceIndex:3 /DestinationImageFile:"%~2\sources\boot.wim" /Bootable /Compress:max
%Dism% /Export-Image /SourceImageFile:"%~1" /SourceIndex:3 /DestinationImageFile:"%~2\sources\boot.wim" /Bootable /Compress:max
goto :eof
rem ############################################################################################
@ -105,28 +109,28 @@ rem ############################################################################
rem 导出镜像 [ %~1 : 镜像路径, %~2 : 目标路径 ]
:ExportImage
if not exist "%~1" ( echo.镜像 %~1 不存在 && goto :eof )
for /f "tokens=2 delims=: " %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%~1" ^| findstr /i Index') do ( call :ExportImageIndex "%~1", %%f, "%~2" )
for /f "tokens=2 delims=: " %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" ^| findstr /i Index') do ( call :ExportImageIndex "%~1", %%f, "%~2" )
goto :eof
rem 导出镜像 [ %~1 : 镜像路径, %~2 : 镜像序号, %~3 : 目标路径 ]
:ExportImageIndex
rem 获取镜像信息
for /f "tokens=3" %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Installation') do ( set "ImageType=%%f" )
for /f "tokens=2,3 delims=:. " %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Version') do ( set "ImageVersion=%%f.%%g" )
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Installation') do ( set "ImageType=%%f" )
for /f "tokens=2,3 delims=:. " %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Version') do ( set "ImageShortVersion=%%f.%%g" )
rem 系统名称
if "%ImageType%" equ "Client" (
if "%ImageVersion%" equ "6.1" ( set "ImageName=Windows 7" )
if "%ImageVersion%" equ "6.2" ( set "ImageName=Windows 8" )
if "%ImageVersion%" equ "6.3" ( set "ImageName=Windows 8.1" )
if "%ImageVersion%" equ "10.0" ( set "ImageName=Windows 10" )
if "%ImageShortVersion%" equ "6.1" ( set "ImageName=Windows 7" )
if "%ImageShortVersion%" equ "6.2" ( set "ImageName=Windows 8" )
if "%ImageShortVersion%" equ "6.3" ( set "ImageName=Windows 8.1" )
if "%ImageShortVersion%" equ "10.0" ( set "ImageName=Windows 10" )
) else if "%ImageType%" equ "Server" (
if "%ImageVersion%" equ "6.1" ( set "ImageName=Windows 2008 R2" )
if "%ImageVersion%" equ "6.2" ( set "ImageName=Windows 2012" )
if "%ImageVersion%" equ "6.3" ( set "ImageName=Windows 2012 R2" )
if "%ImageVersion%" equ "10.0" ( set "ImageName=Windows 2016" )
if "%ImageShortVersion%" equ "6.1" ( set "ImageName=Windows 2008 R2" )
if "%ImageShortVersion%" equ "6.2" ( set "ImageName=Windows 2012" )
if "%ImageShortVersion%" equ "6.3" ( set "ImageName=Windows 2012 R2" )
if "%ImageShortVersion%" equ "10.0" ( set "ImageName=Windows 2016" )
) else ( goto :eof )
rem 系统版本
for /f "tokens=3" %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Edition') do ( set "ImageEdition=%%f" )
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Edition') do ( set "ImageEdition=%%f" )
if "%ImageEdition%" equ "Cloud" ( goto :eof )
if "%ImageEdition%" equ "CoreCountrySpecific" ( set "ImageName=%ImageName% 家庭中文版" )
if "%ImageEdition%" equ "CoreSingleLanguage" ( set "ImageName=%ImageName% 家庭单语言版" )
@ -139,16 +143,25 @@ if "%ImageEdition%" equ "ServerEnterprise" ( set "ImageName=%ImageName%
if "%ImageEdition%" equ "ServerWeb" ( set "ImageName=%ImageName% Web版" )
if "%ImageEdition%" equ "ServerDatacenter" ( set "ImageName=%ImageName% 数据中心版" )
rem 处理器架构
rem for /f "tokens=3" %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Architecture') do ( set "ImageArch=%%f" )
rem for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Architecture') do ( set "ImageArch=%%f" )
rem if "%ImageArch%" equ "x86" ( set "ImageName=%ImageName% 32位" )
rem if "%ImageArch%" equ "x64" ( set "ImageName=%ImageName% 64位" )
rem 判断是否有重复镜像
for /f "tokens=3" %%f in ('Dism /English /Get-ImageInfo /ImageFile:"%~3" /Name:"%ImageName%" ^| findstr /i Index') do ( echo 镜像 %ImageName% 已存在 %%f && goto :eof )
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~3" /Name:"%ImageName%" ^| findstr /i Index') do ( echo 镜像 %ImageName% 已存在 %%f && goto :eof )
rem 导出格式
if /i "%~x3" equ ".wim" ( set "Compress=/Compress:max" )
if /i "%~x3" equ ".esd" ( set "Compress=/Compress:recovery" )
Dism /Export-Image /SourceImageFile:"%~1" /SourceIndex:%~2 /DestinationImageFile:"%~3" /DestinationName:"%ImageName%" %Compress%
%Dism% /Export-Image /SourceImageFile:"%~1" /SourceIndex:%~2 /DestinationImageFile:"%~3" /DestinationName:"%ImageName%" %Compress%
goto :eof
rem 删除文件 [ %~1 : 文件路径 ]
:RemoveFile
if exist "%~1" del /f /q "%~1"
goto :eof
rem 删除目录 [ %~1 : 目录路径 ]
:RemoveFolder
if exist "%~1" rd /q /s "%~1"
goto :eof
:Exit
if "%~1" equ "" pause

View File

@ -35,75 +35,80 @@ goto :Start
rem 处理镜像 [ %~1 : 镜像文件路径 ]
:MakeWim
if /i "%~x1" equ ".esd" ( call :MakeESD "%~1" && goto :eof )
for /f "tokens=3" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%~1" ^| findstr /i Index') do ( set "ImageCount=%%f" )
for /l %%f in (1, 1, %ImageCount%) do call :MakeWimIndex "%~1", %%f, "%MNT%"
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" ^| findstr /i Index') do ( set "ImageCount=%%f" )
for /l %%f in (1, 1, %ImageCount%) do call :MakeWimIndex "%~1", "%%f"
call :ImageOptimize "%~1"
rem 导出为ESD镜像
if /i "%~x2" equ ".esd" %Dism% /Export-Image /SourceImageFile:"%~1" /All /DestinationImageFile:"%~2" /CheckIntegrity /Compress:recovery
goto :eof
rem 处理镜像 [ %~1 : 镜像文件路径 ]
:MakeESD
setlocal
set "WimPath=%TMP%\%~n1.wim"
Dism.exe /Export-Image /SourceImageFile:"%~1" /All /DestinationImageFile:"%WimPath%" /CheckIntegrity /Compress:max
call :MakeWim "%WimPath%", "%~1"
set "WimPath=%TMP%\%~n1_%time:~0,2%%time:~3,2%%time:~5,2%.wim"
%Dism% /Export-Image /SourceImageFile:"%~1" /All /DestinationImageFile:"%WimPath%" /Compress:max
call :MakeWim "%WimPath%"
rem 导出为ESD镜像
call :RemoveFile "%~1"
%Dism% /Export-Image /SourceImageFile:"%WimPath%" /All /DestinationImageFile:"%~1" /Compress:recovery
call :RemoveFile "%WimPath%"
endlocal
goto :eof
rem 处理镜像 [ %~1 : 镜像文件路径, %~2 : 镜像序号, %~3 : 挂载路径 ]
rem 处理镜像 [ %~1 : 镜像文件路径, %~2 : 镜像序号 ]
:MakeWimIndex
call :GetImageInfo "%~1", %~2
call :GetImageInfo "%~1", "%~2"
title 正在处理 [%~2] 镜像 %ImageName% 版本 %ImageVersion% 语言 %ImageLanguage%
%Dism% /Mount-Wim /WimFile:"%~1" /Index:%~2 /MountDir:"%~3"
call :RemoveAppx "%~3"
for /f %%f in ('type "%~dp0Pack\RemoveList.%ImageVersion%.%ImageArch%.txt" 2^>nul') do call :RemoveComponent "%~3", "%%f"
call :IntRollupFix "%~3"
call :AddAppx "%~3", "DesktopAppInstaller", "VCLibs.14"
call :AddAppx "%~3", "Store", "Runtime.1.6 Framework.1.6"
call :AddAppx "%~3", "FoxitMobilePDF"
call :ImportOptimize "%~3"
call :ImportUnattend "%~3"
call :ImageClean "%~3"
%Dism% /Commit-Image /MountDir:"%~3"
call :ImportUnattend "%~3", "Admin"
call :ImageClean "%~3"
%Dism% /Commit-Image /MountDir:"%~3" /Append
%Dism% /Unmount-Wim /MountDir:"%~3" /Discard
%Dism% /Mount-Wim /WimFile:"%~1" /Index:%~2 /MountDir:"%MNT%"
call :MakeWimClean "%MNT%"
rem 处理Admin分卷
set /a "ImageAdmin=%ImageCount%+%~2"
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" ^| findstr /i Index') do ( set "Index=%%f" )
if "%Index%" leq "%ImageCount%" goto :eof
%Dism% /Export-Image /SourceImageFile:"%~1" /SourceIndex:%~2 /DestinationImageFile:"%TMP%\%~nx1"
%Dism% /Export-Image /SourceImageFile:"%~1" /SourceIndex:%ImageAdmin% /DestinationImageFile:"%TMP%\%~nx1" /DestinationName:"%ImageName% [Admin]"
%Dism% /Export-Image /SourceImageFile:"%~1" /SourceIndex:%Index% /DestinationImageFile:"%TMP%\%~nx1" /DestinationName:"%ImageName% [Admin]"
goto :eof
rem 处理lopatkin镜像 [ %~1 : 镜像文件路径, %~2 : 镜像序号, %~3 : 挂载路径 ]
:MakeWimIndex2
call :GetImageInfo "%~1", %~2
title 正在处理 [%~2] 镜像 %ImageName% 版本 %ImageVersion% 语言 %ImageLanguage%
%Dism% /Mount-Wim /WimFile:"%~1" /Index:%~2 /MountDir:"%~3"
rem 处理原版镜像 [ %~1 : 镜像挂载路径 ]
:MakeWimClean
call :RemoveAppx "%~1"
for /f %%f in ('type "%~dp0Pack\RemoveList.%ImageVersion%.txt" 2^>nul') do call :RemoveComponent "%~1", "%%f"
call :IntRollupFix "%~1"
call :AddAppx "%~1", "DesktopAppInstaller", "VCLibs.14"
call :AddAppx "%~1", "Store", "Runtime.1.6 Framework.1.6"
call :AddAppx "%~1", "FoxitMobilePDF"
call :ImportOptimize "%~1"
call :ImportUnattend "%~1"
call :ImageClean "%~1"
%Dism% /Commit-Image /MountDir:"%~1"
call :ImportUnattend "%~1", "Admin"
call :ImageClean "%~1"
%Dism% /Commit-Image /MountDir:"%~1" /Append
%Dism% /Unmount-Wim /MountDir:"%~1" /Discard
goto :eof
rem 处理lopatkin镜像 [ %~1 : 镜像挂载路径 ]
:lopatkin
rem 修复默认用户头像
xcopy /E /I /H /R /Y /J "%~dp0Pack\UAP\%ImageShortVersion%\*.*" "%~3\ProgramData\Microsoft\User Account Pictures" >nul
call :MountImageRegistry "%~3"
xcopy /E /I /H /R /Y /J "%~dp0Pack\UAP\%ImageShortVersion%\*.*" "%~1\ProgramData\Microsoft\User Account Pictures" >nul
call :MountImageRegistry "%~1"
rem 修复默认主题
call :RemoveFolder "%~3\Windows\Web\Wallpaper\Theme1"
call :RemoveFile "%~3\Windows\Resources\Themes\Theme1.theme"
call :RemoveFolder "%~1\Windows\Web\Wallpaper\Theme1"
call :RemoveFile "%~1\Windows\Resources\Themes\Theme1.theme"
reg add "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\LastTheme" /v "ThemeFile" /t REG_EXPAND_SZ /d "%%SystemRoot%%\Resources\Themes\Aero.theme" /f >nul
rem 修复设备管理器英文
for /f "tokens=2 delims=@," %%j in ('reg query "HKLM\TK_SYSTEM\ControlSet001\Control\Class" /v "ClassDesc" /s ^| findstr /i inf') do (
for %%i in (System32\DriverStore\zh-CN INF) do (
for %%f in (%SystemRoot%\%%i\%%j*) do %NSudo% cmd.exe /c copy /Y "%%f" "%~3\Windows\%%i\%%~nxf"
for %%f in (%SystemRoot%\%%i\%%j*) do %NSudo% cmd.exe /c copy /Y "%%f" "%~1\Windows\%%i\%%~nxf"
)
)
call :UnMountImageRegistry
call :ImportOptimize "%~3"
call :ImportOptimize "%~1"
if "%ImageType%" equ "Server" (
call :ImportUnattend "%~3"
call :ImportUnattend "%~1"
) else (
call :ImportUnattend "%~3", "Admin"
call :ImportUnattend "%~1", "Admin"
)
call :ImageClean "%~3"
%Dism% /Unmount-Wim /MountDir:"%~3" /Commit
call :ImageClean "%~1"
%Dism% /Unmount-Wim /MountDir:"%~1" /Commit
goto :eof
rem ############################################################################################
@ -152,7 +157,7 @@ if not exist "%WinrePath%" (
echo.保存镜像 [%WinrePath%]
%Dism% /Unmount-Wim /MountDir:"%TMP%\RE" /Commit /Quiet
echo.优化镜像 [%WinrePath%]
%Dism% /Export-Image /SourceImageFile:"%~1\Windows\System32\Recovery\Winre.wim" /All /DestinationImageFile:"%WinrePath%" /CheckIntegrity /Compress:max /Quiet
%Dism% /Export-Image /SourceImageFile:"%~1\Windows\System32\Recovery\Winre.wim" /All /DestinationImageFile:"%WinrePath%" /Compress:max /Quiet
)
copy /Y "%WinrePath%" "%~1\Windows\System32\Recovery\Winre.wim" >nul
endlocal
@ -189,6 +194,9 @@ if "%ImageShortVersion%" equ "10.0" (
Reg add "HKLM\TK_NTUSER\Software\Microsoft\Windows\CurrentVersion\Holographic" /v "FirstRunSucceeded" /t REG_DWORD /d "0" /f >nul
rem 启用照片查看器
%NSudo% cmd.exe /c "%~dp0Pack\Optimize\Photo.cmd"
rem 延迟功能更新
if "%ImageVersion%" leq "10.0.15063" Reg add "HKLM\TK_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "DeferFeatureUpdatesPeriodInDays" /t REG_DWORD /d "365" /f >nul
rem 右键菜单优化
call :ImportRegistry "%~dp0Pack\Optimize\Context.reg"
call :ImportStartLayout "%~1", "%~dp0Pack\StartLayout.xml"
)
@ -357,12 +365,12 @@ goto :eof
rem 获取镜像基本信息 [ %~1 : 镜像文件路径, %~2 : 镜像序号 ]
:GetImageInfo
for /f "tokens=2 delims=:" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Name') do ( set "ImageName=%%f" )
for /f "tokens=3" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Architecture') do ( set "ImageArch=%%f" )
for /f "tokens=3" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Version') do ( set "ImageVersion=%%f" )
for /f "tokens=3" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Edition') do ( set "ImageEdition=%%f" )
for /f "tokens=3" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Installation') do ( set "ImageType=%%f" )
for /f "tokens=* delims=" %%f in ('Dism.exe /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Default') do ( set "ImageLanguage=%%f" && set "ImageLanguage=!ImageLanguage:~1,-10!" )
for /f "tokens=2 delims=:" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Name') do ( set "ImageName=%%f" )
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Architecture') do ( set "ImageArch=%%f" )
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Version') do ( set "ImageVersion=%%f" )
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Edition') do ( set "ImageEdition=%%f" )
for /f "tokens=3" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Installation') do ( set "ImageType=%%f" )
for /f "tokens=* delims=" %%f in ('%Dism% /English /Get-ImageInfo /ImageFile:"%~1" /Index:%~2 ^| findstr /i Default') do ( set "ImageLanguage=%%f" && set "ImageLanguage=!ImageLanguage:~1,-10!" )
for /f "tokens=1,2 delims=." %%f in ('echo %ImageVersion%') do ( set "ImageShortVersion=%%f.%%g" )
goto :eof
@ -376,10 +384,10 @@ goto :eof
rem 清理文件
:CleanUp
call :UnMountImageRegistry
if exist "%MNT%\Windows" ( Dism.exe /Unmount-Wim /MountDir:"%MNT%" /ScratchDir:"%TMP%" /Discard /Quiet )
if exist "%TMP%\RE\Windows" ( Dism.exe /Unmount-Wim /MountDir:"%TMP%\RE" /ScratchDir:"%TMP%" /Discard /Quiet )
Dism.exe /Cleanup-Mountpoints /Quiet
Dism.exe /Cleanup-Wim /Quiet
if exist "%MNT%\Windows" ( %Dism% /Unmount-Wim /MountDir:"%MNT%" /ScratchDir:"%TMP%" /Discard /Quiet )
if exist "%TMP%\RE\Windows" ( %Dism% /Unmount-Wim /MountDir:"%TMP%\RE" /ScratchDir:"%TMP%" /Discard /Quiet )
%Dism% /Cleanup-Mountpoints /Quiet
%Dism% /Cleanup-Wim /Quiet
call :RemoveFolder "%TMP%"
call :RemoveFolder "%MNT%"
if errorlevel 0 goto :eof
@ -398,5 +406,4 @@ goto :eof
:Exit
call :CleanUp
endlocal EnableDelayedExpansion
title 操作完成
if "%~1" equ "" pause
title 操作完成