How can I find out which process is locking a file or folder in Windows?

For instance, when trying to delete a folder, Windows reports this:

The action can't be completed because the folder is open in another program

Happens the same with a file, but how do I find out what program or application is currently using it and preventing me from deleting the file or folder?

  • 4
    See this ServerFault question. – John Fouhy Jul 17 '09 at 3:34
  • 2
  • 1
    Is your file a video? You may find that Windows Explorer itself is "using" the file... – DisgruntledGoat Mar 12 '12 at 10:32
  • 26
    How is this a duplicate? He's specifically asking how to find out which process is locking a file, not how to delete a locked file. – b1nary.atr0phy Mar 16 '15 at 2:15
  • 8
    I can't add an built-in, simpler answer here because it was incorrectly marked as a dupe, nor can I add it to the other thread because that only applies to XP. But anyway, for Windows versions with Resource Monitor (type it in search bar), go to CPU tab/Associated Handles, then search for the file or folder. – jontyc Jun 15 '15 at 0:54
up vote 38 down vote accepted

PowerShell method:

IF((Test-Path -Path $FileOrFolderPath) -eq $false) {
    Write-Warning "File or directory does not exist."       
}
Else {
    $LockingProcess = CMD /C "openfiles /query /fo table | find /I ""$FileOrFolderPath"""
    Write-Host $LockingProcess
}

The openfiles command needs to have support for local files enabled, by running openfiles /local on and restarting.

More details How to find out which process is locking a file or folder in Windows

  • For some reason this just returned an empty string for me. I did run PS ISE in administrator mode too. – Dib Jun 26 '17 at 11:52
  • 8
    The feature must first be enabled with openfiles /local on – mstrange Jul 5 '17 at 17:02
  • 4
    Unfortunately, openfiles seems not to work on a 64-bit Windows: ERROR: The target system must be running a 32 bit OS. – Thomas S. Nov 2 '17 at 10:55
  • Works on Win10 64 for me – Michael Feb 7 at 21:12
  • Running this gave me the same Access is Denied error I was getting originally, and then always printed out the does not exist error message. The below answer, however, gave me the information I needed - IIS was locking the directory I needed to change. – Chris Thompson Jun 20 at 16:40
up vote 486 down vote
+50

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. Open the CPU tab and use the search field in the Associated Handles section
    • 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!

Resource Monitor screenshot

  • 15
    Note: the Resource Monitor didn't find any associated handles in my case whereas Process Explorer (as described above) did. – ComFreek May 6 '14 at 16:57
  • 13
    @ComFreek Well, ProcessExplorer might be more powerful in many cases, but for me Resource Monitor have always found the application locking the file I'm trying to do something with. I also prefer it to Process Explorer simply because it's right there in the OS. No need for an extra download and an extra shortcut somewhere. – Svish May 6 '14 at 21:16
  • 5
    I couldn't find this in Process Explorer, but it was easy to locate with these instructions in Resource Manager. Thanks. – Tatiana Racheva Aug 8 '14 at 4:30
  • 5
    @ComFreek In my case it was just the other case: Process Explorer didn't find the handle, whereas Resource Monitor did. – Uwe Keim Nov 25 '15 at 13:24
  • 6
    +1 - this also works just fine on Windows 10 – Matt Innes Jun 1 '16 at 15:03

A couple of options:

Microsoft/SysInternals Process Explorer - Go to Find > Find Handle or DLL. In the "Handle or DLL substring:" text box, type the path to the file (e.g. "C:\path\to\file.txt") and click "Search". All processes which have an open handle to that file should be listed.

WhoLockMe - Explorer extension which adds a right-click menu option

N.B. WhoLockMe appears to not work with Win 10 (at least I have been unable to register it with either of the 32- or 64-bit versions of regsvr32.exe).

  • 26
    In Windows 7, if you try to delete a file that is locked, the error message will tell you which process has it locked – Garry English Sep 25 '12 at 17:16
  • 9
    NOTE: Unlocker installs Adware if you are not careful. From their website: "Promotional feature: Fully optional Delta toolbar." – Julian Knight Mar 13 '14 at 21:50
  • 11
    @GarryEnglish for some reason this isn't always the case. I just had to use procexp to tell me that notepad++ had a lock on a folder. Windows 7 was unable to tell me the culprit. – GuiSim Jul 1 '14 at 20:19
  • 4
    @jpmc26 No. WhoLockMe does not work on Windows 7. – ceving Nov 28 '14 at 19:39
  • 3
    @GarryEnglish- As stated by GuiSim, this is for sure not always the case, and in my experience, it is rarely the case. – dgo Sep 14 '15 at 16:03

Have a look at Process Explorer (procexp.exe).

From its introduction:

Ever wondered which program has a particular file or directory open? Now you can find out.

To find out what process is using a specific file follow these steps:

  1. Go to Find, Find Handle or DLL.. or simply press Ctrl+F.

    Enter image description here

  2. Enter the name of the file and press Search.

    Enter image description here

  3. Process Explorer will list all processes that have a handle to the file open. Click on an entry to focus the process in the main window.

    Enter image description here

  4. Optionally, you can then even close the handle manually through the lower pane (Ctrl+L):

    Enter image description here

  • 6
    Process Hacker also can do it. – Benoit Mar 12 '12 at 10:41
  • 4
    As another answer mentions, Handle is a command line tool from SysInternals that will also accomplish this task. – heavyd Dec 11 '13 at 22:35
  • I forgot a cmd proces open in the folder, proces explorer helped me notice it. – davejal Dec 20 '16 at 13:33
  • Note to Googlers, current version of PE appears to no longer support Close Handle – MickyD Dec 12 '17 at 8:09
  • Failed to work in Win10 64-bit 1709 – K7AAY Aug 30 at 15:39

LockHunter can unlock any handlers that may have locked your files or folders. Unlike similar freewares, it supports both 32 and 64-bit Windows.

It is a free tool to delete files blocked by something you do not know. LockHunter is useful for fighting against malware, and other programs that are blocking files without a reason. Unlike other similar tools it deletes files into the recycle bin so you may restore them if deleted by mistake.

  • Shows processes locking a file or folder
  • Allows to unlock, delete, copy or rename a locked file
  • Allows to kill locking process
  • Allows to remove locking processes from hard drive
  • Integrates in to Explorer menu
  • It deletes files into the recycle bin, so you may restore them if deleted by mistake
  • Supports both 32 and 64bit Windows
  • 2
    Top two answers didn't work me and the next upvoted ones were either blocked by my firewall or warned not to go to by my chrome!. LockHunter worked perfectly. – user3885927 Jul 19 '16 at 17:45
  • 1
    Luck hunter has worked for me when others haven't – SheldonH Dec 8 '16 at 23:13

EMCO UnlockIT can identify the process that has locked the file as well as unlock the file so that you may delete/edit/move it. The program is completely free, though the newer version is a bit slower and more bloated than the original (which had a plain, unskinned GUI, but loaded pretty much instantaneously and without an annoying splash screen). Also, the original version used to pop up automatically whenever the error you mentioned is triggered, allowing you to instantly unlock the file and perform the operation you were attempting.

Still, UnlockIT is an incredibly useful program that provides a basic functionality that is critically missing from Windows. It's among the standard toolkit of utilities that I install on all Windows computers I work on.

  • @John: Well, it does identify the program that has locked a file. And you can still manually kill the process through task manager. However, it's usually simpler to just unlock the file (especially when it's explorer that has locked the file most of the time) instead of having the kill the process that has locked it (usually due to having accessed the file and left the file handler open due to a program glitch). – Lèse majesté Mar 12 '12 at 3:46

Here was my discovery & solution.

Incidentally, none of the above answers solved my problem.

I even tried using UNLOCKER which proved worthless.

My problem was that of Memeo Autosync Backup

Apparently, this backup process leaves enough of a "ghost like file." This "ghost like file," would show up whenever I would ALT-TAB my computer (Windows Professional XP), i.e. I would see TWO MS Excel Programs running, when I only had ONE visible, on my TASK BAR.

I came across this solution when I thought it might have been the SYMANTEC Endpoint (Anti-Virus) Protection; and disabled the program. However, I kept getting the error message:

cannot delete (LARGE.xls file): It is being used by another person or program. Close any programs that might be using this file and try again.

I subsequently kept seeing the Memeo notice of "syncing" and QUIT the program.

Subsequently, NO ERROR.

For you, it could be ANY of these background saves.

If you do not know the program the file it is using then you can go to My Computer; right click; select Manage. Under System Tools > Shared folders > Open Files, you should be able to see the user who has locked the file. You can close file from here and then you can perform the task of rename or delete the file. Hope this helps

  • 1
    This will only work for shared folders. – sweetfa Aug 14 '13 at 3:57

Additional possibility, just to save people the time I just spent:

In older versions of Windows, you might get "Access Denied - you might not have rights, or the file might be in use". If you find through Process Explorer that the files are, in fact, not opened by anyone, odds are that there is an issue with security. Using an administrator account, select the files in Explorer, right-click and select Properties, Security, Advanced, Owner. Odds are that the files are owned by an account that no longer exists or can no longer be verified to exist (because of changing Active Directory trust settings).

Change ownership to Administrators and you are good to go.

protected by Community Sep 3 '15 at 16:24

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.