Find out which process is locking a file or folder in Windows

For Windows 7, 8 and 10 you can use the built-in Resource Monitor for this.

  1. Open Resource Monitor, which can be found by searching for resmon.exe in the start menu, or as a button on the Performance tab in your Task Manager.

  2. Use the search field in the Associated Handles section on the CPU tab
    pointed at by blue arrow in screen shot below.

In case it’s not obvious, when you’ve found the handle, you can identify the process by looking at the Image and/or PID column.

You can then close the application if you are able to do that, or just right-click the row and you’ll get the option of killing the process right there. Easy peasy!

Remark: The complete text and the picture above are taken from one of the answers to the question on superuser.com.
Some of the comments there claim that sometimes they could not find handles with Resmon but could find them with Process Explorer. Some others claim they could not find handles with Process Explorer but with Resmon.

I’d like to add, if you are looking for the directory C:\alpha\beta\gamma, you can enter in the search field
* gamma or GAMMA or \Gamma
* beta\gamma
* beta or \beta\
* C:\alpha\beta\gamma
* You cannot use slashes instead of backslashes.