Untitled
快速回答:
在 Windows 下,你可以用 openfiles 或 Sysinternals 的 handle.exe 來查詢是哪個 process 正在鎖定檔案或資料夾。這些工具都能在命令提示字元 (CMD) 中使用。
| 方法 | 工具/指令 | 使用方式 | 注意事項 |
|---|---|---|---|
| 內建工具 | openfiles /query |
先啟用:openfiles /local on,重開機後再執行 openfiles /query /fo table \| find /I "<檔案路徑>" |
必須事先啟用,否則查不到本機檔案 |
| Sysinternals 工具 | handle.exe |
安裝:winget install Microsoft.Sysinternals.Handle,再執行 handle.exe <檔案或資料夾名稱> |
不需重開機,結果更完整 |
| GUI 工具 | Resource Monitor (resmon) |
在「CPU → Associated Handles」搜尋檔案名稱 | 需手動操作 GUI,不是純 CMD |
| 進階 GUI 工具 | Process Explorer | Ctrl+F 搜尋檔案名稱,顯示相關 process |
可直接關閉 handle,但需謹慎 |
Sources:
啟用 openfiles 功能:
openfiles /local on
(執行後需要重開機)
查詢目前被鎖定的檔案:
openfiles /query /fo table | find /I "C:\Users\Juiwen\Documents\test.txt"
這會顯示 PID (Process ID) 與檔案路徑,讓你知道是哪個程式鎖住。
使用 Sysinternals Handle 工具:
handle.exe C:\Users\Juiwen\Documents\test.txt
會列出所有正在使用該檔案的 process。
openfiles 或 handle.exe 查詢,不要直接強制關閉。| File5 | File | Last Modified |
|---|---|---|
| Everything極高速Windows 檔案搜尋工具 | Everything極高速Windows 檔案搜尋工具 | 1:25 AM - December 07, 2025 |
| Windows多種命令列工具搜尋檔案 | Windows多種命令列工具搜尋檔案 | 8:21 PM - December 06, 2025 |
| Windows 如何用where找檔案 | Windows 如何用where找檔案 | 8:21 PM - December 06, 2025 |
| Windows PowerShell Execution Policy | Windows PowerShell Execution Policy | 8:21 PM - December 06, 2025 |
| windows batch file with path name | windows batch file with path name | 8:21 PM - December 06, 2025 |