|
这个小工具作用就是将官方网上下载的 KB 形式的Win7、Win8的系统补丁封装入wim文件,将自己找到的Win7、Win8的稳定硬件驱动封装入wim文件中的映像中,
还有利用Win8 原版ISO为系统映像开启.Net3.5/2支持。唯一需要一点准备工作就是把本批处理和映像、补丁放在同一个目录,当然系统必须支持Dism操作,应该不难吧。关于Win7的操作,太古老了,没有多费墨。
@echo off
title Dism装载卸载基本操作_Marc倾力提供
@echo ------------------------------------------------------------------------------
rd %systemdrive%\users\Dir_Test>nul 2>nul
md %systemdrive%\users\Dir_Test>nul 2>nul||(Echo 请使用右键管理员身份运行&&Pause >nul&&Exit)
rd %systemdrive%\users\Dir_Test>nul 2>nul
color 0a
setlocal enabledelayedexpansion
echo 首先说下本批处理的主要用途与用法
echo 用途1:将官方网上下载的 KB 形式的Win7、Win8的系统补丁封装入wim文件,
echo 用途2:将自己找到的Win7、Win8的稳定硬件驱动封装入wim文件中的映像中,
echo 用途3:调整Win7、Win8的部分系统功能,如使用Win8原版ISO开启.Net3.5/2支持。
echo -------------------------------------------------------------------------------
echo 用法:在同一目录准备好要封装的wim文件、系统驱动补丁和本批处理,如d:\backup。
echo d:\backup\Driver,d:\backup\patch,是固定目录,分别放置驱动和补丁子目录。
echo 如d:\backup\Driver\下,拷贝生成d:\backup\Driver\Drv_Win8_x64
echo 如d:\backup\patch\下,拷贝生成d:\backup\patch\patch_Win8_x64
echo 如果调整Win7、Win8的系统部分功能,可能还要准备Win8原版光盘,或者IE10安装包。
echo 请尽量不要在低版本系统里面操作高版本系统映像,出错概率较高。
echo -------------------------------------------------------------------------------
pause
set /p OpDriver=请问是否封装硬件驱动?是输入小写y,不是,随便输个!----
set /p OpPackage=请问是否封装系统补丁?是输入小写y,不是,随便输个!----
set /p bIsWin8Wim=请问映像是Win8吗?输入y,如果是Win7并且要关闭功能和封装IE10,输入n----
if !bIsWin8Wim!==n goto ForWin7
set /p bEnableFeature8=映像是Win8,请问是否开启.Net3.5/2支持?是y,不n----
if !bEnableFeature8!==n goto ForWin7
set /p Letter=程序暂停,开启.Net3.5/2支持,请装载Win8原版ISO,并准确输入盘符----
:ForWin7
if not exist %~dp0mount goto md
:rd_Mount
dir %~dp0mount /ad /b /s >%~dp0del_rd.txt
for /f "usebackq delims=" %%i in (%~dp0del_rd.txt) do ((takeown /f "%%i" /r /d y >%~dp0del_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 %~dp0mount /r /d y >%~dp0del_log.txt>nul 2>nul
@echo y|icacls %~dp0mount /t /q /grant administrator:f>nul 2>nul
rd %~dp0mount /s /q>nul 2>nul
if exist %~dp0mount goto rd_Mount
:md
md %~dp0mount
::准备部分全局变量
set /a a=0
dir %~dp0*.wim /b /s >%~dp0fbackup.txt
cls
echo 查找到%~dp0目录下所有映像文件如下表
echo -----------------------------------------------------
for /f "usebackq delims=" %%i in (%~dp0fbackup.txt) do (
set /a a+=1
echo 系统映像:!a! %%i)
if !a!==0 (
echo 无系统映像文件,直接退出
goto End)
echo -----------------------------------------------------
:SourceWimInput
set /p ChoiceWim=请输入要封装系统序号,只有序号有效,输完请按回车----
for /l %%i in (1,1,!a!) do (
if !ChoiceWim!==%%i (goto ValidSourceInput)
)
echo 这么简单的选择题都会错,输入数字1-!a!有这么难吗,请重新输入
echo -----------------------------------------------------
goto SourceWimInput
:ValidSourceInput
echo 你选择的是第!ChoiceWim!个系统映像文件,马上下一步
set /a a=0
set fileWim=Null
for /f "usebackq delims=" %%i in (%~dp0fbackup.txt) do (
set /a a+=1
if !a!==!ChoiceWim! (
set fileWim=%%i
echo !fileWim!)
)
dism /get-wiminfo /wimfile:!fileWim!
echo 1、下面要输入安装系统的索引号,可以向上滚动显示刚才映像文件信息.
echo 2、只有数字有效,输完请按回车,其它任意键退出
set /p Index=3、请输入要封装系统的索引号----
if not !OpDriver!==y goto AddPackages
dir %~dp0Driver /d /b >%~dp0pbackup.txt
cls
set /a a=0
echo 查找到%~dp0Driver目录下所有子目录如下表
for /f "usebackq delims=" %%i in (%~dp0pbackup.txt) do (
set /a a+=1
echo 系统驱动目录:!a! %%i)
if !a!==0 (
echo 无无任何驱动目录,尝试进行补丁封装
goto AddPackages)
:DriverInput
set /p ChoicePath=请输入要封装驱动目录,只有序号有效,输完请按回车----
for /l %%i in (1,1,!a!) do (
if !ChoicePath!==%%i (
goto ValidDriverInput)
)
echo 这么简单的选择题都会错,输入数字1-!a!有这么难吗,请重新输入
echo -----------------------------------------------------
goto DriverInput
:ValidDriverInput
echo 你选择的是第!ChoicePath!个驱动目录,稍候封装
set /a a=0
::nameDriver这个变量仅仅是完整目录的一部分
set nameDriver=Null
for /f "usebackq delims=" %%i in (%~dp0pbackup.txt) do (
set /a a+=1
if !a!==!ChoicePath! (
set nameDriver=%%i
echo !nameDriver!)
)
:AddPackages
if not !OpPackage!==y goto StartDism
dir %~dp0patch /d /b >%~dp0pbackup.txt
set /a a=0
echo 查找到%~dp0patch目录下所有子目录如下表,仅查子目录
for /f "usebackq delims=" %%i in (%~dp0pbackup.txt) do (
set /a a+=1
echo 系统补丁目录:!a! %%i)
if !a!==0 (
echo 无任何补丁目录,直接退出
goto End)
:PackageInput
set /p ChoicePath=请输入要封装补丁目录,只有序号有效,输完请按回车
for /l %%i in (1,1,!a!) do (
if !ChoicePath!==%%i (
goto ValidPackageInput)
)
echo 这么简单的选择题都会错,输入数字1-!a!有这么难吗,请重新输入
echo -----------------------------------------------------
goto PackageInput
:ValidPackageInput
echo 你选择的是第!ChoicePath!个补丁目录,马上开始封装
set /a a=0
::namePatch这个变量仅仅是完整目录的一部分
set namePatch=Null
for /f "usebackq delims=" %%i in (%~dp0pbackup.txt) do (
set /a a+=1
if !a!==!ChoicePath! (
set namePatch=%%i
echo !namePatch!)
)
::注意此时fbackup.txt文件内容是所有补丁的带完整目录的文件名。
dir %~dp0!namePatch! /b /s >%~dp0\fbackup.txt
:StartDism
::到此时准备工作才做完,挂载映像文件
dism /mount-wim /wimfile:!fileWim! /index:!Index! /mountdir:%~dp0mount
if !OpDriver!==y dism /image:%~dp0mount /add-driver /driver:%~dp0Driver\!nameDriver! /recurse /forceunsigned
if !OpPackage!==y ( for /f "usebackq delims=" %%i in (%~dp0fbackup.txt) do ( dism /image:%~dp0mount /add-
package /packagepath:%%i ) )
if !bIsWin8Wim!==y (
if !bEnableFeature8!==y dism /image:%~dp0mount /enable-Feature /FeatureName:netfx3 /Source:!Letter!:
\sources\sxs
goto Unmount
)
echo 调整功能独立操作,以增强批处理兼容性,连Win7 Starter都可以用。
dism /Image:%~dp0mount /Disable-Feature /FeatureName:TabletPCOC
dism /Image:%~dp0mount /Disable-Feature /FeatureName:WindowsGadgetPlatform
dism /Image:%~dp0mount /Disable-Feature /FeatureName:MediaCenter
dism /Image:%~dp0mount /Disable-Feature /FeatureName:FaxServicesClientPackage
dism /Image:%~dp0mount /Disable-Feature /FeatureName:Printing-XPSServices-Features
dism /Image:%~dp0mount /Disable-Feature /FeatureName:Xps-Foundation-Xps-Viewer
dism /Image:%~dp0mount /Disable-Feature /FeatureName:Printing-Foundation-InternetPrinting-Client
dism /Image:%~dp0mount /Disable-Feature /FeatureName:Hearts
dism /Image:%~dp0mount /Disable-Feature /FeatureName:Solitaire
dism /Image:%~dp0mount /Disable-Feature /FeatureName:SpiderSolitaire
dism /Image:%~dp0mount /Disable-Feature /FeatureName:FreeCell
dism /Image:%~dp0mount /Disable-Feature /FeatureName:Minesweeper
dism /Image:%~dp0mount /Disable-Feature /FeatureName:PurblePlace
dism /Image:%~dp0mount /Disable-Feature /FeatureName:Chess
dism /Image:%~dp0mount /Disable-Feature /FeatureName:Shanghai
dism /Image:%~dp0mount /Disable-Feature /FeatureName:InboxGames
dism /Image:%~dp0mount /Disable-Feature /FeatureName:OpticalMediaDisc
:: dism /image:%~dp0mount /add-package /packagepath:e:\lite\ie10\ie-win7.cab /packagepath:e:\lite
\ie10\ielangpack-CHS.CAB
:: dism /image:%~dp0mount /add-package /packagepath:e:\lite\ie10\IE-Hyphenation-NEU.msu /packagepath:e:
\lite\ie10\IE-Spelling-NEU.msu
:Unmount
set /p bCommit=请问是否保存映像,y/n----
if not !bCommit!==y goto Discard
::保存卸载系统映像
dism /unmount-wim /mountdir:%~dp0mount /commit
goto End
:Discard
dism /unmount-wim /mountdir:%~dp0mount /discard
:End
dir %~dp0mount /ad /b /s >%~dp0del_rd.txt
for /f "usebackq delims=" %%i in (%~dp0del_rd.txt) do ((takeown /f "%%i" /r /d y >%~dp0del_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 %~dp0mount /r /d y >%~dp0del_log.txt>nul 2>nul
@echo y|icacls %~dp0mount /t /q /grant administrator:f>nul 2>nul
rd %~dp0mount /s /q>nul 2>nul
del /f /s /q %~dp0del_rd.txt
del /f /s /q %~dp0del_log.txt
del /f /s /q %~dp0fbackup.txt
del /f /s /q %~dp0pbackup.txt
pause
|
评分
-
查看全部评分
|