if exist %~dp0ie\%%i\ielangpack-CHS.CAB dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\ielangpack-CHS.CAB /Scratchdir:!LPartSource!:\tmp_Imagex
if exist %~dp0ie\%%i\ielangpack-zh-cn.CAB dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\ielangpack-zh-cn.CAB /Scratchdir:!LPartSource!:\tmp_Imagex
if exist %~dp0ie\%%i\IE-Hyphenation-neu.msu dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Hyphenation-neu.msu /Scratchdir:!LPartSource!:\tmp_Imagex
if exist %~dp0ie\%%i\IE-Hyphenation-en.msu dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Hyphenation-en.msu /Scratchdir:!LPartSource!:\tmp_Imagex
if exist %~dp0ie\%%i\IE-Spelling-neu.msu dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Spelling-neu.msu /Scratchdir:!LPartSource!:\tmp_Imagex
if exist %~dp0ie\%%i\IE-Spelling-en.msu dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Spelling-en.msu /Scratchdir:!LPartSource!:\tmp_Imagex
这段代码判断ie目录下是否存在那4个ie补丁文件,因为Win7 ie10/ie11补丁文件名字不一样,所以分别判断。另外,更新IE10/11需要的预备补丁,我都放在那126个补丁里面了,具体是哪一个我现在也记不清了,想细究大家自己Google或者Bing,百度什么都不懂。
我的同事说过,所谓的干部工作就是摸清所有人的底细,掌握每个人为了位子、地方所能承受的底限,是提前说还是日后再说,有些人真TM垃圾,连老婆都可以牺牲。补丁的集成,如果全靠手工命令输入,那的确是烦死了,那么长的名字,非常容易出错,那我在拔苗助长后就再把大家拉一拉,看看还有没有提升的空间。这段批处理流程应该很简单了,大家可以使用,也可以修改优化。
del /f /s /q %temp%\InfoDism.txt>nul 2>nul
echo.
echo 1:本批处理、驱动和补丁子目录、IE升级包必需都在当前目录。
echo 在同目录中有\Driver、\patch和\IE固定目录,放置驱动和补丁子目录。
echo 如\Driver\Drv_Win8_x64,\patch\patch_Win8_x64
echo 调整Win7、Win8功能,可能还要准备Win8原版光盘,或者IE10安装包。
echo.
echo 2:当前目录下工作子目录,挂载文件夹\Mount,临时文件夹\tmp_Imgex。
echo 临时文件*.txt都在系统临时文件夹%temp%中。
echo.
pause
::准备全局变量
set /a a=0
set /a CountWim=0
set /a CountIndex=0
set /a NumWimSource=0
set /a IndexSource=0
::准备局部变量
set /a CountPatch=0
set /a NumPatch=0
set /a CountDrv=0
set /a NumDrv=0
set /a CountIE=0
set /a NumIE=0
cls
echo.
::准备源系统映像文件与索引序号。
set bHvLSr=n
for /l %%i in (1,1,5) do (
if !bHvLSr!==n (
set /p LPartSource=请输入系统映像文件所在盘,不带冒号----
if not exist !LPartSource!: echo 这个盘符根本就没有使用了,你不要搞笑好吧
if exist !LPartSource!: set bHvLSr=y
)
)
dir !LPartSource!:\*.wim /b /s >%temp%\fSeek.txt
echo 查找到!LPartSource!分区下所有映像文件如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do ( set /a a+=1&&echo 系统映像:!a! %%i)
set /a CountWim=!a!
if !a!==0 echo 该分区无系统映像文件,退出重来吧!&&goto End
::准备临时文件夹\tmp_Imagex,预备以后作为ScratchDir使用,这段代码不能随意移动位置!
::目的是1:在PE中临时文件空间不足,源文件盘空间一般没问题;2:如果源文件在固态盘,要充分利用固态盘速度优势。
if not exist !LPartSource!:\tmp_Imagex md !LPartSource!:\tmp_Imagex
if exist !LPartSource!:\tmp_Imagex rd /s /q !LPartSource!:\tmp_Imagex&&md !LPartSource!:\tmp_Imagex
::准备局部文件夹\mount
if not exist !LPartSource!:\mount md !LPartSource!:\mount
if exist !LPartSource!:\mount (
:rd
dir !LPartSource!:\mount /ad /b /s >%temp%\del_rd.txt
for /f "usebackq delims=" %%i in (%temp%\del_rd.txt) do ((takeown /f "%%i" /r /d y >%temp%\del_log.txt>nul 2>nul)&(@echo y|icacls "%%i" /t /q /grant administrator:f>nul 2>nul )&(rd
"%%i" /s /q>nul 2>nul))
takeown /f !LPartSource!:\mount /r /d y >%temp%\del_log.txt>nul 2>nul
@echo y|icacls !LPartSource!:\mount /t /q /grant administrator:f>nul 2>nul
rd !LPartSource!:\mount /s /q
if exist !LPartSource!:\mount goto :rd
del /f /s /q %temp%\del_log.txt>nul 2>nul
del /f /s /q %temp%\del_rd.txt>nul 2>nul
md !LPartSource!:\mount
)
set /p NumWimSource=请输入系统映像文件序号,我不检测无效序号,不带冒号----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumWimSource!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你没有输入有效系统映像文件序号,退出重来吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do (
set /a a+=1
if !NumWimSource!==!a! Dism /get-imageinfo /imagefile:%%i
)
echo.
set /p IndexSource=请输入系统映像索引序号,我不检测无效序号,不带冒号----
echo.
set bDrvDism=y
set /p bDrvDism=请问是否封装硬件驱动?默认是y,直接回车/不是输入小写n----
echo.
if not !bDrvDism!==n (
cls
set /a a=0
dir %~dp0Driver /d /b >%temp%\dirDrvSeek.txt
echo 查找到%~dp0Driver目录下所有子目录,仅查子目录
for /f "usebackq delims=" %%i in (%temp%\dirDrvSeek.txt) do (
set /a a+=1
echo 所有子目录:!a! %%i)
set /a CountDrv=!a!
if !CountDrv!==0 echo 无任何Driver子目录&&set bDrvDism=n
echo -----------------------------------------------------
if not !CountDrv!==0 (
set /p NumDrv=请输入Driver子目录序号,不带冒号----
set bVldDrv=n
for /l %%i in (1,1,!CountDrv!) do (
if !NumDrv!==%%i set bVldDrv=y
)
if !bVldDrv!==n echo 你没有输入有效Driver子目录序号,退出重来吧!&&goto End
)
)
echo.
set bPatDism=y
set /p bPatDism=请问是否封装系统补丁?默认是y,直接回车/不是输入小写n----
echo.
if not !bPatDism!==n (
cls
set /a a=0
dir %~dp0patch /d /b >%temp%\dirPatSeek.txt
echo 查找到%~dp0patch目录下所有子目录,仅查子目录
for /f "usebackq delims=" %%i in (%temp%\dirPatSeek.txt) do (
set /a a+=1
echo 所有子目录:!a! %%i)
set /a CountPatch=!a!
if !CountPatch!==0 echo 无任何patch子目录&&set bPatDism=n
echo -----------------------------------------------------
if not !CountPatch!==0 (
set /p NumPatch=请输入patch子目录序号,不带冒号----
set bVldPat=n
for /l %%i in (1,1,!CountPatch!) do (
if !NumPatch!==%%i set bVldPat=y
)
if !bVldPat!==n echo 你没有输入有效patch子目录序号,退出重来吧!&&goto End
)
)
echo.
set bIsWin8=y
set /p bIsWin8=请问映像版本是否Win8?默认是y,直接回车/不是输入小写n----
if not !bIsWin8!==n (
echo.
set bEnabNet3=y
set /p bEnabNet3=请问是否启用 .Net 3.5/2支持?默认是y,直接回车/不是输入小写n----
if not !bEnabNet3!==n (
echo.
set /p LabelISO=请插入光盘或者装载ISO,并准确输入盘符!----
)
)
::要为Win7封装IE11/IE10,必须封装预备补丁,4-9个。
if !bIsWin8!==n (
set bDisabFun=y
set /p bDisabFun=请问是否关闭Win7部分功能?默认是y,直接回车/不是输入小写n----
set bDismIE10=y
set /p bDismIE10=请问是否封装IE10/IE11?默认是y,直接回车/不是输入小写n----
if not !bDismIE10!==n (
echo IE10升级包在当前目录子目录IE下!
set /a a=0
dir %~dp0IE /d /b >%temp%\dirIESeek.txt
echo 查找到%~dp0IE目录下所有子目录,仅查子目录
for /f "usebackq delims=" %%i in (%temp%\dirIESeek.txt) do (
set /a a+=1
echo 所有子目录:!a! %%i)
set /a CountIE=!a!
if !CountIE!==0 echo 无任何IE子目录&&set bDismIE10=n
echo -----------------------------------------------------
if not !CountIE!==0 (
set /p NumIE=请输入IE子目录序号,不带冒号----
set bVldIE=n
for /l %%i in (1,1,!CountIE!) do (
if !NumIE!==%%i set bVldIE=y
)
if !bVldIE!==n echo 你没有输入有效IE子目录序号,退出重来吧!&&goto End
)
)
)
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do (
set /a a+=1
if !NumWimSource!==!a! dism /mount-image /imagefile:"%%i" /index:!IndexSource! /mountdir:!LPartSource!:\mount /Scratchdir:!LPartSource!:\tmp_Imagex
)
if not !bDrvDism!==n (
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\dirDrvSeek.txt) do (
set /a a+=1
if !NumDrv!==!a! (
dism /image:!LPartSource!:\mount /add-driver /driver:"%~dp0Driver\%%i" /recurse /forceunsigned /Scratchdir:!LPartSource!:\tmp_Imagex >>%temp%\InfoDism.txt
)
)
)
if not !bPatDism!==n (
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\dirPatSeek.txt) do (
set /a a+=1
if !NumPatch!==!a! dir "%~dp0patch\%%i" /b /s >%temp%\fPatSeek.txt
)
for /f "usebackq delims=" %%j in (%temp%\fPatSeek.txt) do (
dism /image:!LPartSource!:\mount /add-package /packagepath:%%j /Scratchdir:!LPartSource!:\tmp_Imagex || echo %%j>>%temp%\InfoDism.txt
)
)
if not !bIsWin8!==n (
if not !bEnabNet3!==n (
dism /image:!LPartSource!:\mount /enable-Feature /FeatureName:netfx3 /Source:!LabelISO!:\sources\sxs /Scratchdir:!LPartSource!:\tmp_Imagex
)
)
if exist %~dp0ie\%%i\ielangpack-CHS.CAB dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\ielangpack-CHS.CAB /Scratchdir:!LPartSource!:\tmp_Imagex
if exist %~dp0ie\%%i\ielangpack-zh-cn.CAB dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\ielangpack-zh-cn.CAB /Scratchdir:!LPartSource!:\tmp_Imagex
if exist %~dp0ie\%%i\IE-Hyphenation-neu.msu dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Hyphenation-neu.msu /Scratchdir:!LPartSource!:
\tmp_Imagex
if exist %~dp0ie\%%i\IE-Hyphenation-en.msu dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Hyphenation-en.msu /Scratchdir:!LPartSource!:
\tmp_Imagex
if exist %~dp0ie\%%i\IE-Spelling-neu.msu dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Spelling-neu.msu /Scratchdir:!LPartSource!:\tmp_Imagex
if exist %~dp0ie\%%i\IE-Spelling-en.msu dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Spelling-en.msu /Scratchdir:!LPartSource!:\tmp_Imagex
)
)
)
)
set bCommit=y
set /p bCommit=请问是否保存映像修改,默认是y,直接回车/不保存输入小写n----
if not !bCommit!==n ( dism /unmount-image /mountdir:!LPartSource!:\mount /commit /Scratchdir:!LPartSource!:\tmp_Imagex )
if !bCommit!==n ( dism /unmount-image /mountdir:!LPartSource!:\mount /discard /Scratchdir:!LPartSource!:\tmp_Imagex )