http://bbs.wuyou.net/forum.php?mod=viewthread&tid=210043
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo 功能:本批處理(溫柔處理版)作用僅僅是把Win7精簡的手動部分自動化了,當然也是把最惡心的一部分自動化了,呵呵,后續部分還得用vLite或其他軟件,網上列表多的是。本批處理首先提取5合1、4合1鏡像中的指定鏡像,然后掛載;溫柔處理版精簡絕大部分打印驅動,MDM驅動,FAX驅動,投影儀驅動(前4部分約占1個GB空間),精簡部分ATI、NV驅動,並且在自備驅動時可安裝打印機,或自動Update驅動;刪除了winsxs中幫助文件,刪除了recovery中winre.wim文件;暴力剩女版按照網上流行的洋鬼子的批處理刪除了其他一些winsxs文件,有可能導致補丁不好打,建議只在極限暴力精簡時使用。本處理全程約60-180分鍾,你可以去運動一會了。本批處理絕對是做母盤或者適度精簡版的的不二選擇!說精簡版不穩定的基本都是農民!本批處理精簡的系統絕對穩定可靠,你還可以設置斷點(pause),修改del_index.txt,log.txt刪除時機(慎重),觀察完整運行過程;本批處理可以二次開發,改變精簡方案,改變功能調整方案,改變驅動(補丁)集成方案,適當編程,適用於win7,2008,X32,X64,8沒試過,應該沒問題,通用性極強;最后本批處理,每一步都是用微軟的矛攻擊微軟的盾,絕無任何隱瞞,絕無任何病毒木馬,與原版一樣安全;建議大家先看下源文件,再隨便試一下(可以出去放會風,或者利用垃圾時間讓電腦自己做),絕對方便簡單;還有它稍作改動,甚至不做改動,只需輸入正確參數,可用作二次精簡工具,你懂的,呵呵!當然本人從今年3月份買入聯想K27才開始玩Win7,批處理也是最近現學現賣,iamgex,dism等操作都是剛入門,肯定有不少不足,歡迎大家斧正(QQ:396854818,htpcfans@yahoo.cn),准備玩轉Win8!現在果斷扔掉WinXP!當然,目前這個批處理已經是獨步全球了。2012年5月,於浙江定海,四個工作日搞定,以副處級公務員黨性保證,這絕對是利器一柄!
@echo -----------------------------------------------------------------------
@echo 請仔細閱讀,謹慎選擇目錄,以免誤操作刪除重要資料。本程序先后順序上實際上還可優化,請高手斧正。
@echo 參數說明:%1,鏡像索引號(1-5);%2,你的機器當前系統管理員名字,最好用是英文的,例如marc。
@echo 輔助說明:所生成精簡版wim文件在d:\lite\下,名字為win7_lite.wim,還有個未集成補丁的備份:win7_lite_Org.wim。
@echo 輔助說明:所生成精簡版wim文件文件體積較大,但實際上文件數肯定減少了,有興趣的后續部分還得用vLite或其他軟件處理。
@echo 輔助說明:一次開機過程盡量只進行一組Dism操作,即只運行一次本批處理,不是我而是微軟惡心。
@echo 請先自行做好以下5項准備工作,其實也易如反掌,不超過5分鍾了。
@echo 注意:1、執行精簡任務,請以管理員身份登錄Win7 ,記住管理員名字,它可是參數2
@echo 注意:2、本批處理默認Win7安裝文件夾放在d:\lite\iso(\sources\install.wim),需先提取整個光盤文件,極力推薦微軟原版。
@echo 注意:3、本批處理默認mount操作文件夾在d:\lite\mount,需先創建。
@echo 注意:4、X32、X64位版本配套的imagex.exe(非gimagex)也放在d:\lite\文件夾下,需先行復制,同時只能有一個版本存在,因為名字固定。
@echo 注意:5、請確保D盤有20GB以上空閑磁盤空間。
@echo 注意:6、執行本批處理請不要用在vLite已精簡過的安裝文件夾(本批處理中所指iso)中,建議重新提取,防止各種無名意外。
@echo 注意:7、X32、X64系統所用的imagex.exe有版本區別,其實更嚴重的是在X32系統中為X64位wim文件打補丁也可能遇到問題。
@echo 注意:8、批處理使用方法例示:d:\mydoc\win7_lite 4 marc
@echo 注意:9、封裝驅動、補丁及語言包見第八階段實例,也可以自己編程設計。
@echo -----------------------------------------------------------------------
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
(@echo 第一階段,大約5-20分鍾,准備工作。)>d:\lite\log.txt
if exist d:\lite\iso\sources goto okISO
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo 兄弟,你的Win7 DVD ISO文件提取路徑不對,或者根本沒提取,我等你看完說明,再解壓好,按任意鍵繼續。或按Ctrl+C 中止退出。
pause
:okISO
if not "%1%"=="" goto okArguments
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo -----------------------------------------------------------------------
@echo 兄弟,你沒輸入參數,我沒法干活,我可是帶詳細指令的批處理,例如:d:\mydoc\win7_lite 4 marc。我自行退出,或你按Ctrl+C 中止。
pause
goto ESC
:okArguments
if not exist d:\lite\del_index.txt goto noDelLog
del /f /s /q d:\lite\del_index.txt
:noDelLog
if not exist d:\lite\mount goto mdMount
::必須先清除子目錄中權限較高的文件夾,才可以清除本級文件夾,Windows的惡心約定,並且微軟還為我設了先有雞還是先有蛋的問題,執行第一遍錯誤百出,我執行了兩次,當然高手可能不怕。友情提示,第一遍時,錯誤百出,讓它多飛一會,沒什么大不了!
dir d:\lite\mount /ad /b /s >d:\lite\del_index.txt
for /f %%i in (d:\lite\del_index.txt) do (@echo y|takeown /f %%i /r >d:\lite\log.txt)
for /f %%i in (d:\lite\del_index.txt) do (@echo y|cacls %%i /t /g %2:f >>d:\lite\log.txt)
for /f %%i in (d:\lite\del_index.txt) do rd %%i /s /q
@echo y|takeown /f d:\lite\mount /r
@echo y|cacls d:\lite\mount /t /g %2:f
rd d:\lite\mount /s /q
dir d:\lite\mount /ad /b /s >d:\lite\del_index.txt
for /f %%i in (d:\lite\del_index.txt) do (@echo y|takeown /f %%i /r >d:\lite\log.txt)
for /f %%i in (d:\lite\del_index.txt) do (@echo y|cacls %%i /t /g %2:f >>d:\lite\log.txt)
for /f %%i in (d:\lite\del_index.txt) do rd %%i /s /q
@echo y|takeown /f d:\lite\mount /r
@echo y|cacls d:\lite\mount /t /g %2:f
rd d:\lite\mount /s /q
:mdMount
md d:\lite\mount
if exist d:\lite\imagex.exe goto existImagex
@echo 兄弟,復制下imagex吧,要不我開不了工!我等着你,OK了,我繼續。
pause
:existImagex
::我要刪除同名文件,甚至是上一次已經做好的,呵呵!
del /f /s /q d:\lite\win7_lite.wim
del /f /s /q d:\lite\del_index.txt
@echo 馬上要開始正式工作了!
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
@echo 第二階段,大約15分鍾以內,從微軟原始安裝盤中應用需要的鏡像(32位5取1或者64位4取1)。
d:\lite\imagex /apply d:\lite\iso\sources\install.wim %1 d:\lite\mount
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
@echo 第三階段,大約20分鍾以內,取得以下文件夾所有權(Takeown),提升權限,完全控制(Cacls)。
::取得以下三個文件夾所有權,提升權限,完全控制。
@echo y|takeown /f d:\lite\mount\windows\winsxs /r
@echo y|cacls d:\lite\mount\windows\winsxs /t /g %2:f
@echo y|takeown /f d:\lite\mount\windows\system32\recovery /r
@echo y|cacls d:\lite\mount\windows\system32\recovery /t /g %2:f
@echo y|takeown /f d:\lite\mount\windows\system32\driverstore\filerepository /r
@echo y|cacls d:\lite\mount\windows\system32\driverstore\filerepository /t /g %2:f
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
@echo 第四階段,大約5分鍾以內,全自動/手動精簡文件。
del /f /s /q d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\recovery\ winre.wim
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*ati*inf*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*ati*inf* >d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*chm*.*
del /f /s /q d:\lite\mount\windows\winsxs\*chm*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*chm* >>d:\lite\del_index.txt
dir /ad /b /s d:\lite\mount\windows\help\*chm* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*fax*.*
del /f /s /q d:\lite\mount\windows\winsxs\*fax*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*fax* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*flpy*.*
del /f /s /q d:\lite\mount\windows\winsxs\*flpy*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*flpy* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*mdm*inf*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*mdm*inf* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*nv*inf*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*nv*inf* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnb*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnb* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnc*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnc* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnfx*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnfx* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prng*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prng* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnh*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnh* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prni*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prni* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnk*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnk* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnl*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnl* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnn*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnn* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prno*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prno* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnr*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnr* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prns*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prns* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnt*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnt* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*prnx*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*prnx* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\winsxs\manifests\*wia*inf*.*
dir /ad /b /s d:\lite\mount\windows\winsxs\*wia*inf* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*ati*inf*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*ati*inf* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*nv*inf*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*nv*inf* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*fax*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*fax* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*mdm*inf*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*mdm*inf* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnb*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnb* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnc*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnc* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnfx*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnfx* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prng*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prng* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnh*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnh* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prni*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prni* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnk*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnk* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnl*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnl* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnn*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnn* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prno*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prno* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnr*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnr* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prns*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prns* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnt*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnt* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*prnx*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*prnx* >>d:\lite\del_index.txt
del /f /s /q d:\lite\mount\windows\system32\driverstore\filerepository\*wia*inf*.*
dir /ad /b /s d:\lite\mount\windows\system32\driverstore\filerepository\*wia*inf* >>d:\lite\del_index.txt
for /f %%j in (d:\lite\del_index.txt) do (rd %%j /s /q)
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
@echo 第五階段,大約15分鍾以內,從剛才應用的在離線系統捕獲鏡像(肯定只有1個鏡像),並復制一個備份,名字加Suffix:_Org。
d:\lite\imagex /capture /compress maximum d:\lite\mount d:\lite\win7_lite.wim "Win7_lite"
copy d:\lite\win7_lite.wim d:\lite\win7_lite_Org.wim
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
@echo 第六階段,大約30分鍾以內,全自動清理三大文件夾;取得其他文件夾所有權(Takeown),提升權限,完全控制(Cacls),全部清理干凈。
rd d:\lite\mount\windows\system32\recovery /s /q
rd d:\lite\mount\windows\system32\driverstore\filerepository /s /q
rd d:\lite\mount\windows\winsxs /s /q
::必須先清除子目錄中權限較高的文件夾,才可以清除本級文件夾,Windows的惡心約定,並且微軟還為我設了先有雞還是先有蛋的問題,執行第一遍錯誤百出,我執行了兩次,當然高手可能不怕。
dir d:\lite\mount /ad /b /s >d:\lite\del_index.txt
for /f %%i in (d:\lite\del_index.txt) do (@echo y|takeown /f %%i /r >d:\lite\log.txt)
for /f %%i in (d:\lite\del_index.txt) do (@echo y|cacls %%i /t /g %2:f >>d:\lite\log.txt)
for /f %%i in (d:\lite\del_index.txt) do rd %%i /s /q
@echo y|takeown /f d:\lite\mount /r
@echo y|cacls d:\lite\mount /t /g %2:f
rd d:\lite\mount /s /q
dir d:\lite\mount /ad /b /s >d:\lite\del_index.txt
for /f %%i in (d:\lite\del_index.txt) do (@echo y|takeown /f %%i /r >d:\lite\log.txt)
for /f %%i in (d:\lite\del_index.txt) do (@echo y|cacls %%i /t /g %2:f >>d:\lite\log.txt)
for /f %%i in (d:\lite\del_index.txt) do rd %%i /s /q
@echo y|takeown /f d:\lite\mount /r
@echo y|cacls d:\lite\mount /t /g %2:f
rd d:\lite\mount /s /q
del /f /s /q d:\lite\del_index.txt
del /f /s /q d:\lite\log.txt
md d:\lite\mount
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
@echo 第七階段,大約15分鍾以內,掛載目標鏡像(肯定只有1個鏡像)。
dism /mount-wim /wimfile:d:\lite\win7_lite.wim /index:1 /mountdir:d:\lite\mount
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
@echo 第八階段,大約15-120分鍾,為目標鏡像封裝補丁與驅動,禁用部分功能,請各位自行編程。
::Sample
Dism /Image:d:\lite\mount /Disable-Feature /FeatureName:MediaCenter
::Sample
dism /image:d:\lite\mount /add-package /packagepath:d:\lite\lp.cab
dism /image:d:\lite\mount /set-uilang:zh-cn
@echo 全自動/手動精簡Win7 批處理,馬寶銀拙作,2012年5月。
@echo -----------------------------------------------------------------------
@echo 第九階段,大約15分鍾以內,保存卸載修改后的目標鏡像(肯定只有1個鏡像)。
Dism /unmount-wim /mountdir:d:\lite\mount /commit
@echo Congratulations! You Win! Press Any Key,Exit.
pause
:ESC
exit
@echo 注意:8、批處理使用方法例示:d:\mydoc\win7_lite 4 marc 這個什么意思?
帶參數批處理用法
本批處理的用法,把它Copy到你隨便哪個目錄里,比如我的在d:\mydoc,本來名字是win7_Lite_暴力剩女版.bat,把它改成方便的名字,比如我把它改成win7_Lite.bat,以管理員身份運行命令提示符,我的管理員名字marc,這是第二個參數,再說下鏡像索引號,32位原版包括入門版、家庭初級版,家庭高級版,專業版,旗艦版,是1-5,64位版包括家庭初級版,家庭高級版,專業版,旗艦版,是1-4。想全自動精簡64位專業版,方法就是先建好目錄,提取好X64位ISO文件,在名令提示符中輸入:"d:\mydoc\win7_lite 3 marc",不帶引號,從前到后就是批處理目錄、名字、索引號和管理員名字,以空格隔開,然后回車,好了,你可以休息2-3個小時了,讓電腦去干吧。