將以下程式碼存為 Win7Maintenance.bat,以管理員權限執行,即可呼叫互動式選單:
@echo off
mode con cols=85 lines=30
title Win7 終極批次維護工具
color 3d
:main
cls
echo 1 - 清理 Win7/Vista 系統垃圾
echo 2 - 修復開啟圖片緩慢
echo 3 - 重啟 Explorer 進程
echo 4 - 開啟系統資源監視器
echo 5 - 清除工作列歷史圖示
echo 6 - 移除捷徑小箭頭
echo 7 - 還原捷徑小箭頭
echo 8 - 優化系統服務 [謹慎]
echo 9 - 清除圖片位置冗余資料夾
echo 0 - 結束
echo a - 修改檔案名稱
echo b - 電腦關機
echo c - 硬碟轉換 NTFS
echo x - 其他資訊
echo d - 清理 XP 系統垃圾
set /p choice=請輸入選項:
if '%choice%'=='1' goto clean7
if '%choice%'=='2' goto fiximg
if '%choice%'=='3' goto restexp
if '%choice%'=='4' goto resmon
if '%choice%'=='5' goto clrhist
if '%choice%'=='6' goto delarrow
if '%choice%'=='7' goto resarrow
if '%choice%'=='8' goto optsvc
if '%choice%'=='9' goto clrpic
if '%choice%'=='a' goto renfile
if '%choice%'=='b' goto shutdown
if '%choice%'=='c' goto convntfs
if '%choice%'=='x' goto info
if '%choice%'=='d' goto cleanxp
if '%choice%'=='0' goto end
goto main
:clean7
echo 正在清理系統垃圾...
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
echo 完成。pause & goto main
:fiximg
reg delete "HKCR\SystemFileAssociations\image\shell\edit\command" /f
reg add "HKCR\SystemFileAssociations\image\shell\edit\command" /ve /d "\"%%systemroot%%\system32\mspaint.exe\" \"%%1\"" /f
echo 圖片關聯已修復。pause & goto main
:restexp
taskkill /f /im explorer.exe
start explorer.exe
echo Explorer 已重啟。pause & goto main
:resmon
start resmon.exe
goto main
:clrhist
del /f /q %appdata%\Microsoft\Windows\Recent\*.*
del /f /q %appdata%\Microsoft\Windows\Recent\AutomaticDestinations\*.*
echo 工作列歷史已清除。pause & goto main
:delarrow
reg delete "HKCR\lnkfile" /v IsShortcut /f
reg delete "HKCR\piffile" /v IsShortcut /f
taskkill /f /im explorer.exe & start explorer.exe
echo 小箭頭已移除。pause & goto main
:resarrow
reg add "HKCR\lnkfile" /v IsShortcut /f
reg add "HKCR\piffile" /v IsShortcut /f
taskkill /f /im explorer.exe & start explorer.exe
echo 小箭頭已還原。pause & goto main
:optsvc
echo 此功能需極度熟悉服務依賴關係,建議手動操作。pause & goto main
:clrpic
rd /s /q "%userprofile%\Pictures\*"
echo 圖片資料夾已清空。pause & goto main
:renfile
set /p newname=輸入新檔名(含副檔名):
ren *.* %newname%
pause & goto main
:shutdown
shutdown -s -t 10 -c "批次排程關機"
goto main
:convntfs
set /p drv=輸入磁碟代號(如 C:):
convert %drv% /fs:ntfs
pause & goto main
:cleanxp
echo 清理 XP 垃圾...
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\recycled\*.*
pause & goto main
:info
echo 版本 1.0 | 僅供參考 | 操作前請備份重要資料
pause & goto main
:end
exit
使用提醒:
這支批次檔整合了日常維護高頻動作,適合進階使用者快速操作,新手請謹慎測試。