A while back we talked about ways to deal with locked files on Windows file shares. This time around, we’ll go into more detail about how you can answer that same question, “who has that file locked?” when dealing with local files and folders.
How many times have you tried to delete a file or folder and been confronted with this old chestnut:
Sometimes you can pretty easily find the source of the lock: a text editor you forgot to close, a command prompt with its working directory somewhere in the folder tree you’re trying to delete, etc. But many times you’re interactively logged into a server with multiple people simultaneously, or maybe it’s late in the day and you’ve lost count of the number of applications and windows you’ve had to open to deal with all the human multitasking (thank goodness for 64-bit Windows and plenty of physical memory, amirite?).
Whatever the situation may be, an easy way to take the guesswork out of finding who has that file locked is to use another great tool from the SysInternals suite: Process Explorer.
Process Explorer is a free download and can be copied over and dropped in wherever you need to run it. It’s basically a Task Manager on steroids and we highly recommend keeping it handy for any and all Windows systems you need to manage. The first time you start it up, you’ll see the process tree for all the processes currently running on your system.
While this tool provides loads of valuable process information, we’re just going to focus on open file handles for now.
Once Process Explorer is up, simply press Control+F, or go to its Find menu and select “Find Handle or DLL…”. In the search box, enter part of the (or the whole) folder or file name you are trying to delete and click the Search button.
Ah-hah! So that “Immortal” folder I was trying to delete is currently in use by a cmd.exe process. If I click on the locking process in the search result, Process Explorer will jump to that process in the process tree where I can see the full details about that process – who’s running it, on what session, etc. No more guessing or badgering people, just the truth. Of course if it was someone else’s process, then it’d be time for badgering!
Again, finding the answer to who has that file locked is just one feature of Process Explorer, we highly recommend trying it out if you haven’t already. It even has the option to replace your default “Task Manager” shortcut in the Task Bar context menu.