Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Win7 一鍵清除所有使用者帳號 Cookie 與瀏覽器暫存檔 (批次檔)

編輯:Windows 7 系統介紹

Windows 7 多使用者環境下,手動清除各帳號 Cookie 耗時。提供批次檔自動掃描所有帳號資料夾並清除 Cookie 與暫存網路檔案。

建立批次檔步驟

  1. 桌面右鍵 → 「新增」→ 「文字文件」

新建文字文件

  1. 貼入以下程式碼:
@echo off
color 0a
cd /d %SystemDrive%
cls
:: Title 正在清理本機所有帳戶下的Cookie和瀏覽器垃圾文件
dir "%SystemDrive%\Users" /ad /b > %SystemDrive%\DirTmp.txt
for /f %%a in (%SystemDrive%\DirTmp.txt) do (
    del /f /s /q "%SystemDrive%\Users\%%a\Cookies\*.*" 2>nul
    del /f /s /q "%SystemDrive%\Users\%%a\AppData\Local\Microsoft\Windows\INetCache\*.*" 2>nul
    del /f /s /q "%SystemDrive%\Users\%%a\AppData\Local\Microsoft\Windows\INetCookies\*.*" 2>nul
)
del /f /q %SystemDrive%\DirTmp.txt
pause

說明:原碼針對 XP (Documents and Settings) 路徑,已更新為 Win7/Vista/10/11 通用的 %SystemDrive%\Users 路徑,並新增 INetCache/INetCookies 現代暫存路徑。

  1. 另存為 CleanAllCookies.bat(副檔名 .bat)
  1. 雙擊執行,視窗顯示清理進度
  1. 執行完成後,C 槽根目錄會產生 DirTmp.txt(帳號清單),可手動刪除

程式碼邏輯解析

指令功能
dir /ad /b列出 Users 目錄下所有資料夾名稱(帳號名)
for /f %%a in (...)逐一處理每個帳號
del /f /s /q強制、遞迴、安靜模式刪除檔案
2>nul隱藏「找不到檔案」等錯誤訊息

注意事項

  • 需以系統管理員身分執行 才能存取其他使用者資料夾
  • 僅清除檔案型 Cookie,不影響瀏覽器資料庫 (SQLite) 型 Cookie(Chrome/Edge/Firefox 現代版本)
  • 現代瀏覽器建議使用內建「清除瀏覽資料」功能
  • 執行前請關閉所有瀏覽器避免檔案鎖定
Copyright © Windows教程網 All Rights Reserved