windows:find_what_process_is_holding_a_file_open
Table of Contents
Windows - Find what process is holding a file open
Sharing violation errors.
Use the Resource Monitor
- Open Resource Monitor, which can be found
- By searching for Resource Monitor or resmon.exe in the start menu, or
- As a button on the Performance tab in your Task Manager
- Go to the CPU tab
- Use the search field in the Associated Handles section
- When you've found the handle, you can identify the process by looking at the Image and/or PID column.
- Try to close the application as you normally would, or, if that's not possible, just right-click the handle and kill the process directly from there.
WARNING: Be very careful with closing handles!
It's even more dangerous than you'd think, because of handle recycling - if you close the file handle, and the program opens something else, that original file handle you closed may be reused for that “something else.”
And now guess what happens if the program continues, thinking it is working on the file (whose handle you closed), when in fact that file handle is now pointing to something else.
Use Sysinternals
To find a specific file, navigate to Find → Find Handle or DLL….
Type in part of the path to the file.
The list of processes will appear below.
If you prefer command line, Sysinternals suite includes command line tool Handle, that lists open handles.
Examples:
c:\Program Files\SysinternalsSuite>handle.exe |findstr /i "e:\" (finds all files opened from drive e:\" c:\Program Files\SysinternalsSuite>handle.exe |findstr /i "file-or-path-in-question"
windows/find_what_process_is_holding_a_file_open.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1