Find the process that locks a file
List open files and find the process locking a Windows file with psfile and handle.
When a file cannot be deleted or modified because another process is using it, two Sysinternals tools can help identify the holder.
Listing remotely opened files with psfile
psfile.exe lists files opened remotely and allows you to close those open handles.
psfile.exe
Finding the process that holds the file with handle
handle.exe lists the handles open on the system. The following filter keeps only the lines of type File:
handle.exe | select-string ': File'
Notes
- Both tools are part of the Sysinternals suite.