📄 系统文件替换.bat
字号:
:cab Compress file (source, target)
attrib -r -s -h %2
:: Overwrite compressed backup files (generally in i386 folders)
:: 覆盖压缩的备份文件(通常在 i386 目录)
makecab/v1 %1 %2 >nul 2>&1 || (
echo/ ! Compress failed.
echo/
call:brk
)
del %fil% 2>nul
exit/b
:hlp Display help
echo/Replaces protected system files.
echo/
echo/ Usage:
echo/ %~n0 "ScriptFile"
echo/
echo/ Example:
echo/ %~n0 "C:\Replacer\Script.txt"
echo/
echo/ Script syntax:
echo/ ;; ReplacerScript
echo/ ; Comment
echo/ SystemFileName [,ReplacementFile] [,Reference#] [,Optional]
echo/
echo/ Script example:
echo/ ;; ReplacerScript
echo/ ; Replace Notepad, Calc, Paint
echo/ notepad.exe,notepad.new
echo/ calc.exe,files\calc.new
echo/ mspaint.exe,"C:\Files\paint.new"
echo/ ; Prompt to optionally restore Notepad from backup
echo/ notepad.exe,RESTORE,Optional
echo/
echo/ See readme.txt for ReferenceNumber details.
exit/b
:idt Identify script format (last 3 tokens, sys)
:: Ugly method of determining which tokens are which
:: 检查对应令牌环的“丑陋”方法
set "sys=%~4"
if /i "%~1"=="Restore" (
if "%~2" LSS "9" (
if "%~2"=="" (
set "typ=R--"
) else (
if "%~2" GEQ "0" (
if /i "%~3"=="Optional" (
set "typ=RNO"
) else (
if /i "%~3"=="" (
set "typ=RN-"
)
)
)
)
) else (
if /i "%~2"=="Optional" (
set "typ=R-O"
)
)
) else (
if "%~1" LSS "9" (
if "%~1"=="" (
set "typ=---"
) else (
if "%~1" GEQ "0" (
if /i "%~2"=="Optional" (
set "typ=-NO"
) else (
if /i "%~2"=="" (
set "typ=-N-"
)
)
)
)
) else (
if /i "%~1"=="Optional" (
set "typ=--O"
) else (
if "%~2" LSS "9" (
if "%~2"=="" (
set "typ=M--"
) else (
if "%~2" GEQ "0" (
if "%~3"=="" (
set "typ=MN-"
) else (
if /i "%~3"=="Optional" (
set "typ=MNO"
)
)
)
)
) else (
if /i "%~2"=="Optional" (
set "typ=M-O"
)
)
)
)
)
if not defined typ (
echo/ ! Format of line unknown.
echo/
exit/b1
) else (
call:\%typ% "%~1" "%~2" "%~3"
)
exit/b0
:exm Examine script (sys)
call:scn "%~1"
if not exist "%pth%\%~nx1" (
echo/ ! System file not found:
echo/ "%~1"
echo/
exit/b1
)
if /i not "%mod%"=="Restore" (
if not exist "%mod%" (
echo/ ! Replacement file not found:
echo/ "%mod%"
echo/
exit/b1
)
)
if not "%num%"=="" (
find/i ":\\%~n1%num%" "%~f0" >nul 2>&1 || (
echo/ ! Invalid reference number:
echo/ "%~nx1,%num%"
echo/
exit/b1
)
)
exit/b0
:opt Handles optional lines in scripts (sys)
if /i "%opt%"=="Optional" (
echo: ? Replace optional file "%~1"? ^(Y/N^)
setlocal enabledelayedexpansion
call:get var
if /i "!var!"=="Y" (
endlocal
call:fmt "%sys%,%mod%,%num%,%opt%"
exit/b
) else (
endlocal
)
) else (
call:fmt "%sys%,%mod%,%num%,%opt%"
exit/b1
)
exit/b0
:fmt Format script
:: Fill in tokens if any are missing
:: 如果有遗漏则填充令牌环
set "var=%~1"
set "var=%var:,,=, ,%"
set "var=%var:,,=, ,%"
>>"%scr%-tmp" echo/%var%
exit/b0
:seq Run sequence (4 ordered tokens)
:: Used when replacing files from script
:: 当用脚本替换文件时使用
set "pth="
if not "%~3"==" " (
call:\\%~n1%~3
) else (
call:scn %1
)
set "sys=%pth%%~nx1"
if /i "%~2"=="Restore" (
set "mod=%pth%%~n1.backup"
) else (
set "mod=%~f2"
)
call:quo sys
call:quo mod
call:chk %sys% || exit/b
call:chk %mod% || exit/b
call:ver %sys% || exit/b
call:rep
exit/b0
:scn Scan Folders
:: Finds the most likely file match when only filename is given
:: (during scripts or system file input)
:: 如果只给定了文件名,则查找最合适的匹配(在脚本、系统文件输入的时候)
set "pth=%~1"
if not "%pth:\=%" == "%pth%" (
set "pth=%~dp1"
) else (
set "pth="
call:\\%~n10 2>nul && exit/b0
:: More common paths at top
:: 通常路径
for %%* in (
"%windir%"
"%windir%\system32"
"%windir%\system32\drivers"
"%windir%\system"
"%programfiles%\Outlook Express"
"%programfiles%\Windows Media Player"
"%windir%\Resources\Themes\Luna"
"%programfiles%\Movie Maker"
"%programfiles%\Windows NT"
"%windir%\PCHEALTH\HELPCTR\Binaries"
"%windir%\Fonts"
"%programfiles%\Internet Explorer"
"%programfiles%\Internet Explorer\Connection Wizard"
"%commonprogramfiles%\Microsoft Shared\MSInfo"
"%programfiles%\Windows NT\Accessories"
"%programfiles%\Windows NT\Pinball"
"%commonprogramfiles%\System"
"%windir%\system32\Restore"
"%windir%\system32\srchasst"
"%windir%\system32\usmt"
"%commonprogramfiles%\Microsoft Shared\Speech"
"%programfiles%\NetMeeting"
"%commonprogramfiles%\System\Mapi\1033"
"%commonprogramfiles%\Adobe\Calibration"
"%programfiles%\Symantec\LiveUpdate"
"%programfiles%\WildTangent\Apps\CDA"
"%programfiles%\Stardock\Object Desktop\IconPackager"
) do (
if not exist %fl2% (
if exist "%%~*\%~nx1" (
set "pth=%%~*\"
type nul > %fl2%
)
)
)
if exist %fl2% del %fl2%
)
exit/b0
:brk Exit Replacer ([Purge] [Now])
:: Clean up and exit
:: 清理,退出
if not "%~1"=="Purge" (
if not "%~1"=="Now" (
echo/
echo/Press any key to quit.
pause >nul
)
)
if /i not "%~1"=="Purge" if exist "%scr%" popd
for %%* in (%vbs% %fil% %flg%
%fl2% "%scr%" %del% "%scr%-tmp" %dlp%
) do if exist %%* del/f %%* >nul 2>&1
if /i not "%~1"=="Purge" (
if exist "%dir%" rd "%dir%" 2>nul
endlocal
:: Use a hard exit to prevent other loops from continuing
:: 如果有其他循环则硬退出
exit
)
exit/b0
:: List of special files requiring more (or less) steps
:: 列出需要更多/更少步骤的特殊文件
:\\Luna
set "fln=luna.mst"
set "atr=wfp"
exit/b0
:\\Shellstyle
if /i not "%pth:Homestead=%"=="%pth%" (
set "fln=home_ss.dll"
)
if /i not "%pth:Metallic=%"=="%pth%" (
set "fln=metal_ss.dll"
)
if /i not "%pth:NormalColor=%"=="%pth%" (
set "fln=blue_ss.dll"
)
if /i not "%pth:\system32\=%"=="%pth%" (
set "fln=class_ss.dll"
)
set "atr=wfp"
exit/b0
:\\Marlett
set "atr=non"
exit/b
:\\Comctl32
if /i not "%pth%"=="%windir%\system32\" (
set "atr=non"
)
exit/b
:\\Commdlg
if /i not "%pth%"=="%windir%\system\" (
set "atr=non"
)
exit/b
:\\Notepad
if /i not "%pth%"=="%windir%\" (
set "atr=non"
)
exit/b
:\\Uxtheme.dll
set "atr=wfp"
:\\Comctl320
set "pth=%windir%\system32\"
exit/b
:\\Comctl321
set "pth=%windir%\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.0.0_x-ww_1382d70a\"
exit/b
:\\Comctl322
set "pth=%windir%\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.10.0_x-ww_f7fb5805\"
exit/b
:\\Comctl323
set "pth=%windir%\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.1331_x-ww_7abf6d02\"
exit/b
:\\Comctl324
set "pth=%windir%\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.1515_x-ww_7bb98b8a\"
exit/b
:\\Comctl325
set "pth=%windir%\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\"
exit/b
:\\Commdlg0
set "pth=%windir%\system\"
exit/b
:\\Commdlg1
set "pth=%windir%\system32\"
exit/b
:\\Notepad0
set "pth=%windir%\"
exit/b
:\\Notepad1
set "pth=%windir%\system32\"
exit/b
:\\Shellstyle0
set "pth=%windir%\system32\"
exit/b
:\\Shellstyle1
set "pth=%windir%\Resources\Themes\Luna\Shell\NormalColor\"
exit/b
:\\Shellstyle2
set "pth="%windir%\Resources\Themes\Luna\Shell\Metallic\"
exit/b
:\\Shellstyle3
set "pth=%windir%\Resources\Themes\Luna\Shell\Homestead\"
exit/b
:: List of script line formats
:: 脚本行格式的列表
:\RNO
set "mod=Restore"
set "num=%~2"
set "opt=%~3"
exit/b
:\R-O
set "mod=Restore"
set "num="
set "opt=%~2"
exit/b
:\RN-
set "mod=Restore"
set "num=%~2"
set "opt="
exit/b
:\R--
set "mod=Restore"
set "num="
set "opt="
exit/b
:\-N-
set "mod=%sys%"
set "num=%~1"
set "opt="
exit/b
:\-NO
set "mod=%sys%"
set "num=%~1"
set "opt=%~2"
exit/b
:\--O
set "mod=%sys%"
set "num="
set "opt=%~1"
exit/b
:\M--
set "mod=%~1"
set "num="
set "opt="
exit/b
:\MN-
set "mod=%~1"
set "num=%~2"
set "opt="
exit/b
:\M-O
set "mod=%~1"
set "num="
set "opt=%~2"
exit/b
:\MNO
set "mod=%~1"
set "num=%~2"
set "opt=%~3"
exit/b
:\---
set "mod=%sys%"
set "num="
set "opt="
exit/b
:: Clear_WFP_Message.vbs -- clears the WFP message
:: 清除WFP消息的脚本
' Clears WFP message
' 清楚WFP消息
const win="Windows File Protection"
const wi2="Unable To Locate Component"
set arg=wscript.arguments
if arg.count then
flg=arg.item(0)
else wscript.echo "Bad parameters."
wscript.quit
end if
set w=wscript.createobject("wscript.shell")
set f=wscript.createobject("scripting.filesystemobject")
x=999
while x > 0
if w.appactivate(win) then
w.sendkeys "{ESC}"
w.sendkeys "{TAB}{ENTER}"
end if
if w.appactivate(wi2) then
w.sendkeys "{ESC}{TAB}{ENTER}"
end if
if f.fileexists(flg) then
x=45
f.deletefile(flg)
end if
wscript.sleep 333
x=x-1
wend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -