5

找出資料夾或檔案被誰鎖定 - 硬漢解法

 2 years ago
source link: https://blog.darkthread.net/blog/find-file-lock-w-sysinternals/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

找出資料夾或檔案被誰鎖定 - 硬漢解法

calendar.svg 2022-07-10 11:40 AM comment.svg 0 eye.svg 4,095

Windows 的檔案有時會因被鎖定無法修改刪除,新版 Windows 很貼心,警示訊息會顯示鎖定來源:補充案例

Fig2_637930212917343148.png

但偶爾會遇到「無法完成動作,因為資料夾或資料夾中的檔案已在其他程式開啟」這種鎖定來源不明的狀況:

Fig1_637930212917961034.png

這種狀況用嘗試一個個檔案更名或刪除的土法子有時能找到兇手,網路上也有不少解決這種問題的專門軟體,但身為作風強悍的茶包射手,為這點小事特別去找軟體一點都不酷,要解 100 種問題,難道要下載或安裝 100 種軟體?活用工具就能解決的事,何必一天到晚花時間去找別人寫好的專用軟體。就像水電維修界有句名言:

沒有噴一次 WD-40 解決不了的問題,如果有,那就噴兩次!

(謎:不要瞎掰好嗎?)

Fig3_637930212919523868.png
圖片來源:男人的香水(WD-40)完整介紹 by 超認真少年

射茶包神器,Sysinternals 魔法工具包,向來是本部落格的固定班底,像是 Process MonitorProcess ExplorerDisk Usage, duAccess CheckProcess DumpRAMMapVMMapTCP ViewHandle... 都曾在文章出現,相信大家應該不陌生。其中 Process Explorer 跟 Handle 就能用來查檔案鎖定。
(如果你常在查 Windows 問題,千萬不要錯過 Sysinternals 工具組,程式每個都很輕薄短小,執行效能又好,免安裝,甚至可以直接從網路磁碟機執行。)

用 Process Explorer 查詢檔案鎖定操作很簡單,但沒那麼直覺,找到 Find/Find Handle or DLL... (或按 Ctrl-Shift-F):

Fig4_637930212919919827.png

輸入檔名或資料夾路徑,按 Search,搞定!

Fig5_637930212920367732.png

如果你覺得滑滑鼠太娘,要開 Cmder/Shell 敲鍵盤下指令才夠 Man,那麼可以用 handle D:\lab\TempMVC,一樣可以得到答案:

Fig6_637930212920745073.png

以上技巧分享給想走硬漢風格的茶包射手們參考。

and has 0 comments

Comments

Be the first to post a comment

Post a comment

Comment
Name Captcha 94 + 1 =

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK