求大家长批量加工

我玩批处理10的时候最佩服,是德国人写的,有英文注释(功能:批处理系统的文件替换)。

* Replacer 2.63预发布版

* www3.telus.net/_/replacer/

*电子邮件:undefined@telus.net

@关闭回声

标题替换者

*检查操作系统

ver | find "NT " >nul & amp& amp(

echo/!不支持Windows NT。

暂停& gt空

转到:eof

)

set local disabled delayed expansion enable extensions

*使用现有的组件

如果存在" %~dp0Components\*。exe "(

set " path = % ~ dp0Components%path% "

标题替换器*

)else(

set " path = % windir % \ system32%path% "

)

*临时目录

set "dir=%~dp0。替换程序"

*对只读媒体使用%tmp%

如果不存在“% dir %”MD“% dir %”2 & gt;nul ||(

set "dir=%tmp%\。替换程序"

md "%tmp%\ "ReplacerTemp " 2 & gt空

)

*用于与其他脚本通信的标志

设置flg="%dir%\..\.Flag_SafeToDel "

set fl2="%dir%\.Flag2_SafeToDel "

*提取的文件

set VBS = " % dir % \ Clear _ WFP _ message . VBS "

*存储重写的脚本

设置“scr=%dir%”。当前脚本"

*存储撤销命令,以防系统无法启动

set und = " % windir % \ replace rundo . txt "

*存储删除的文件

set del = " % dir % \ deleted file _ SafeToDel "

呼叫:刹车清洗

额外的VBScript嵌入在底部

findstr/rc:"^[]" " % ~ dpnx 0 " & gt;% vbs % 2 & gtnul ||(

echo/!无法提取嵌入文件。尝试使用以下网站提供的组件包:

echo/ %sys%

)

)

如果定义了pth(

对于(%sys%)中的%%*,do(

set sys = " % PTH % %~NX * "

)

)

呼叫:chk %sys% ||(

echo/按任意键继续。

暂停& gt空

转到:系统

)

*检查脚本是否作为系统文件给出

对于(%sys%)中的%%*,do(

if /i "%%~x*"== "。txt "(

查找/我";;ReplacerScript " % % * & gtnul & amp& amp(

呼叫:scr %%*

)

)

)

调用:ver %sys% || goto:sys

:mod获取替换文件

cls

设置“mod=”

将替换的%nam%回显/拖动到此窗口中。

如果存在%bak%(

echo/或,键入RESTORE以还原%nam%的备份。

)

然后,按回车键继续。

echo/或,键入Q退出。

call:get mod || goto:mod

呼叫:quo mod

if /i %mod%=="Q "呼叫:brk Now

if /i %mod%=="RESTORE "(调用:rst || goto:mod)

呼叫:chk %mod% ||(

echo/按任意键继续。

暂停& gt空

转到:模式

)

if /i %mod%==%sys%(

echo/!文件不能自我替换。

回声/

echo/按任意键继续。

暂停& gt空

)& amp& amp转到:模式

:cnf确认操作

cls

if %mod%==%bak%(

将恢复回显/文件。

)else(

如果存在%bak%(

将不备份echo/File,备份已经存在。

)else(

对于(%sys%)中的%%*,do(

echo/文件将备份到:

echo/"%%~dpn*。备份"

)

)

)

回声/

回显/当前文件:

echo/%sys%

echo/将替换为:

echo/%mod%

回声/

回声/继续?^(Y/N^)

调用:get cnf || goto:cnf

电话:quo cnf

如果/i不是" %cnf:~1,1%"=="Y "呼叫:brk Now

cls

:vbs启动VBScript

*一个标志告诉VBScript何时退出,因此WFP消息仍然可以

*在Replacer.cmd退出后清除

如果存在%flg% del %flg%

如果不是" %atr%"=="non "(

start " "/below normal wscript//b % VBS % % flg % | |(

echo/VBScript失败:

echo/%vbs%

回声/

)

)

如果存在“%scr%”退出/b

:rep替换文件

如果存在%und% del/f %und%

如果不存在“%scr%”(

echo/ * %nam%:

)

*用替换文件覆盖系统文件

if /i not %mod%==%bak%(

如果不存在%bak%(

echo/ -备份...

呼叫:cpy %sys% %bak%

)

)

*并非所有文件都受到保护

如果不是" %atr%"=="non "(

如果存在%dll%(

echo/ -复制到DllCache...

调用:cpy %mod% %dll%

)

如果存在%spf%(

echo/ -复制到ServicePackFiles...

致电:cpy %mod% %spf%

)

如果存在%c86%(

echo/ -压缩到i386文件夹...

致电:cpy %mod% %fil%

致电:cab %fil% %c86%

)

如果存在%w86%(

echo/ -压缩到Windows i386文件夹...

致电:cpy %mod% %fil%

致电:cab %fil% %w86%

)

如果存在%d86%(

echo/ -复制到驱动程序缓存...

致电:cpy %mod% %d86%

)

)

if /i %mod%==%bak%(

echo/ -恢复系统文件...

)else(

echo/ -替换系统文件...

)

*简单地重命名文件绕过了WFP;

:: "%~1"

如果不存在" %pth%\%~nx1 "(

echo/!找不到系统文件:

echo/ "%~1 "

回声/

出口/b1

)

if /i not "%mod%"=="Restore "(

如果不存在“%mod%”(

echo/!找不到替换文件:

echo/ "%mod% "

回声/

出口/b1

)

)

如果不是“% num %”= = " "(

find/I ":\ \ % ~ n 1% num % " " % ~ F0 " & gt;nul 2 & gt& amp1 || (

echo/!无效的参考编号:

echo/ "%~nx1,%num% "

回声/

出口/b1

)

)

退出/b0

:opt处理脚本中的可选行(sys)

if /i "%opt%"== "可选" (

回声:?替换可选文件“%~1”?^(Y/N^)

setlocal enabledelayedexpansion

呼叫:获取var

如果/我”!var!”=="Y "(

结束本地

调用:fmt " %系统%,%修改%,%数量%,%优化% "

退出/b

)else(

结束本地

)

)else(

调用:fmt " %系统%,%修改%,%数量%,%优化% "

出口/b1

)

退出/b0

:fmt格式脚本

*如果缺少代币,请填写代币

set "var=%~1 "

set "var=%var:,,=,% "

set "var=%var:,,=,% "

& gt& gt" %scr%-tmp "回显/%var%

退出/b0

:序列运行序列(4个有序令牌)

*在替换脚本中的文件时使用

设置“pth=”

如果不是“% ~ 3”= = " "(

调用:\\%~n1%~3

)else(

致电:scn %1

)

设置" sys=%pth%%~nx1 "

if /i "%~2"=="Restore "(

设置“mod=%pth%%~n1.backup”

)else(

设置“mod=%~f2”

)

呼叫:quo sys

呼叫:quo mod

调用:chk %sys% || exit/b

调用:chk %mod% ||退出/b

调用:版本%sys% ||退出/b

致电:代表

退出/b0

:scn扫描文件夹

*当只给出文件名时,查找最可能匹配的文件

::(在脚本或系统文件输入期间)

设置“pth=%~1”

如果不是" %pth:\=%" == "%pth% "(

设置“pth=%~dp1”

)else(

设置“pth=”

来电:\ \ % ~ n 10 2 & gt;nul & amp& amp退出/b0

*高层更常见的路径

对于%%* in(

" %windir% "

" %windir%\system32 "

" %windir%\system32\drivers "

" %windir%\system "

" %programfiles%\Outlook Express "

" % program files % \ Windows Media Player "

" %windir%\Resources\Themes\Luna "

" %programfiles%\Movie Maker "

" %programfiles%\Windows NT "

" % windir % \ PCHEALTH \ help CTR \ Binaries "

" %windir%\Fonts "

" % program files % \ Internet Explorer "

" % program files % \ Internet Explorer \连接向导"

" % common program files % \ Microsoft Shared \ MSInfo "

" % program files % \ Windows NT \ Accessories "

" % program files % \ Windows NT \ Pinball "

" %commonprogramfiles%\System "

" %windir%\system32\Restore "

" % windir % \ system32 \ srchasst "

" %windir%\system32\usmt "

" % common program files % \ Microsoft Shared \ Speech "

" %programfiles%\NetMeeting "

" % common program files % \ System \ Mapi \ 1033 "

" % common program files % \ Adobe \ Calibration "

" % program files % \ Symantec \ live update "

" % program files % \ wild tangent \ Apps \ CDA "

" % program files % \ star dock \ Object Desktop \ icon packager "

)做(

如果不存在%fl2%(

如果存在" %%~*\%~nx1 "(

设置" pth=%%~*\ "

nul类型& gt%fl2%

)

)

)

如果存在%fl2% del %fl2%

)

退出/b0

:brk退出替换程序([清除][立即])

*清理和退出

如果不是" %~1"=="Purge "(

如果不是" %~1"== "现在" (

回声/

echo/按任意键退出。

暂停& gt空

)

)

if /i not "%~1"=="Purge "如果存在" %scr%" popd

对于(%vbs% %fil% %flg%中的%%*

% fl2 % " % SCR % " % del % " % SCR %-tmp " % DLP %

)do if exist % % * del/f % % * & gt;nul 2 & gt& amp1

if /i not "%~1"=="Purge "(

如果存在“% dir %”rd“% dir %”2 & gt;空

结束本地

*使用硬退出来防止其他循环继续下去

出口

)

退出/b0

*需要更多(或更少)步骤的特殊文件清单

:\ \露娜

设置“fln=luna.mst”

设置“atr=wfp”

退出/b0

:\\Shellstyle

if/I not " % PTH:Homestead = % " = " % PTH % "(

设置“fln=home_ss.dll”

)

if/I not " % PTH:Metallic = % " = " % PTH % "(

设置“fln=metal_ss.dll”

)

if/I not " % PTH:normal color = % " = " % PTH % "(

设置“fln=blue_ss.dll”

)

if/I not " % PTH:\ system32 \ = % " = = " % PTH % "(

设置" fln=class_ss.dll "

)

设置“atr=wfp”

退出/b0

:\\Marlett

设置“atr=non”

退出/b

:\\Comctl32

if/I not " % PTH % " = " % windir % \ system32 \ "(

设置“atr=non”

)

退出/b

:\\Commdlg

if/I not " % PTH % " = " % windir % \ system \ "(

设置“atr=non”

)

退出/b

:\ \记事本

if/I not " % PTH % " = " % windir % \ "(

设置“atr=non”

)

退出/b

:\\Uxtheme.dll

设置“atr=wfp”

:\\Comctl320

设置“pth=%windir%\system32”

退出/b

:\\Comctl321

set " PTH = % windir % \ WinSxS \ x86 _ Microsoft。windows . Common-Controls _ 6595 b 64144 CCF 1df _ 6 . 0 . 0 . 0 _ x-ww _ 1382 d70a \ "

退出/b

:\\Comctl322

set " PTH = % windir % \ WinSxS \ x86 _ Microsoft。windows . Common-Controls _ 6595 b 64144 CCF 1df _ 6 . 0 . 10.0 _ x-ww _ f7fb 5805 \ "

退出/b

:\\Comctl323

set " PTH = % windir % \ WinSxS \ x86 _ Microsoft。windows . Common-Controls _ 6595 b 64144 CCF 1df _ 6 . 0 . 2600 . 1331 _ x-ww _ 7 abf 6d 02 \ "

退出/b

:\\Comctl324

set " PTH = % windir % \ WinSxS \ x86 _ Microsoft。windows . Common-Controls _ 6595 b 64144 CCF 1df _ 6 . 0 . 2600 . 1515 _ x-ww _ 7 bb 98 b 8 a \ "

退出/b

:\\Comctl325

set " PTH = % windir % \ WinSxS \ x86 _ Microsoft。windows . Common-Controls _ 6595 b 64144 CCF 1df _ 6 . 0 . 2600 . 2180 _ x-ww _ a84f 1ff 9 \ "

退出/b

:\\Commdlg0

设置“pth=%windir%\system”

退出/b

:\\Commdlg1

设置“pth=%windir%\system32”

退出/b

:\ \记事本0

设置“pth=%windir%\”

退出/b

:\\Notepad1

设置“pth=%windir%\system32”

退出/b

:\\Shellstyle0

设置“pth=%windir%\system32”

退出/b

:\\Shellstyle1

设置“PTH = % windir % \ Resources \ Themes \ Luna \ Shell \ normal color”

退出/b

:\\Shellstyle2

set " PTH = " % windir % \ Resources \ Themes \ Luna \ Shell \ Metallic \ "

退出/b

:\\Shellstyle3

设置“PTH = % windir % \ Resources \ Themes \ Luna \ Shell \ Homestead”

退出/b

*脚本行格式列表

:\RNO

设置“mod=Restore”

设置“数量=%~2”

设置“opt=%~3”

退出/b

:\R-O

设置“mod=Restore”

设置“数量=”

设置“opt=%~2”

退出/b

:\RN-

设置“mod=Restore”

设置“数量=%~2”

设置“opt=”

退出/b

:\R -

设置“mod=Restore”

设置“数量=”

设置“opt=”

退出/b

:\-N-

设置“mod=%sys%”

设置" num=%~1 "

设置“opt=”

退出/b

:\-不

设置“mod=%sys%”

设置" num=%~1 "

设置“opt=%~2”

退出/b

:\ - O

设置“mod=%sys%”

设置“数量=”

设置" opt=%~1 "

退出/b

:\M -

设置" mod=%~1 "

设置“数量=”

设置“opt=”

退出/b

:\MN-

设置" mod=%~1 "

设置“数量=%~2”

设置“opt=”

退出/b

:\M-O

设置" mod=%~1 "

设置“数量=”

设置“opt=%~2”

退出/b

:\MNO

设置" mod=%~1 "

设置“数量=%~2”

设置“opt=%~3”

退出/b

:\ -

设置“mod=%sys%”

设置“数量=”

设置“opt=”

退出/b

* Clear _ WFP _ message . VBS-清除WFP消息

清除WFP消息

const win="Windows文件保护"

const wi2= "无法定位组件"

set arg=wscript.arguments

如果arg.count那么

flg =参数item(0)

else wscript.echo“错误参数”

wscript.quit

如果…就会结束

set w = wscript . createobject(" wscript . shell ")

set f = wscript . createobject(" scripting . file system object ")

x=999

而x & gt0

如果w.appactivate(win)则

w . sendkeys“{ ESC }”

w . sendkeys“{ TAB } { ENTER }”

如果…就会结束

如果w.appactivate(wi2)则

w . sendkeys“{ ESC } { TAB } { ENTER }”

如果…就会结束

如果f . file存在(flg ),则

x=45

f .删除文件(flg)

如果…就会结束

wscript.sleep 333

x=x-1