码迷,mamicode.com
首页 > Windows程序 > 详细

[原创] Win7全自动精简批处理_绝对原创,绝对给力_感谢无忧给了我一年的潜水

时间:2016-12-06 09:25:36      阅读:1190      评论:0      收藏:0      [点我收藏+]

标签:compress   src   磁盘空间   man   win7   打补丁   win8   运行   联想   

2011htpcfans发表于 2012-5-5

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

技术分享

win7_lite_温柔处女版.rar

@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个小时了,让电脑去干吧。

 

[原创] Win7全自动精简批处理_绝对原创,绝对给力_感谢无忧给了我一年的潜水

标签:compress   src   磁盘空间   man   win7   打补丁   win8   运行   联想   

原文地址:http://www.cnblogs.com/liuzhaoyzz/p/6136187.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!