Find Which Process Has Locked a File Without 3rd Party Tools

When you attempt to delete a file or folder which is in use by a process, the File In Use dialog appears showing the name of the program that has locked the file.

However, there are cases where the “File In Use” dialog doesn’t show the name of the process that has a lock on the file you’re trying to delete. In some cases, the dialog will show “the action can’t be completed because the file is open in another process“.

Find Which Process Has Locked a File

For investigating processes and locked files, Windows Sysinternals Process Explorer is probably the first option that comes to mind for most users. However, there are two built-in solutions to display the current open files list along with corresponding process names.

Resource Monitor

Resource Monitor (resmon.exe) is a built-in tool that has many useful features. With Resource Monitor, you can track current network and internet usage, view associated handles for locked files, as well as manage processes just as you’d using the Task Manager.

To find the process name that has a file locked, click the CPU tab, type the file name or part of it in the Associated Handles text box.

Find Which Process Has Locked a File

We’ve covered Resource Monitor earlier. Check out these articles:

OpenFiles.exe — a built-in console tool

Another built-in tool we’re going to use is Openfiles.exe, a console tool that’s not new to Windows. It was originally introduced in 2000 as part of the Windows Resource Kit 2000/2003 tools. This utility was then included by default in Windows Vista and higher (including Windows 10). Openfiles displays the currently open files list from local or shared folders, along with the Handle ID and Process executable name. This tool also allows you to disconnect one or more files that are opened remotely from a shared folder.

Enable “Maintain Objects List” global flag for the First time

First, to enable tracking of local file handles, you need to turn on ‘maintain objects list’ flag by running the following command from admin Command Prompt.

openfiles /local on

You’ll see the following message:

INFO: The system global flag ‘maintain objects list’ is currently enabled.

You’ll need to run this command for the first time only. Then restart Windows for the change to take effect.

View open files and the corresponding process names

After restarting Windows, from an admin Command Prompt window, type:


This lists the File/Handle ID, Process Name and the list of files opened locally or opened remotely via local share points, in a table format.

To view the output in List or CSV formats, use the /query parameter.

openfiles /query /FO LIST
openfiles /query /FO CSV

To copy the output to clipboard, pipe the output to Clip.exe as below. Then paste the output in Notepad or any other editor of your choice.

openfiles |clip

Find Which Process Has Locked a File

openfiles /query /FO LIST |clip
openfiles /query /FO CSV |clip

Find Which Process Has Locked a File

For more information on copying Command Prompt output to clipboard or save the output to a file, check out the article How to Copy Command Prompt Output Text to Clipboard or Save to File?

To find if a particular file is being in use by a program (and to know which program), you may use the following command-line.

openfiles | findstr /i <filename>


openfiles | findstr /i eiffel

The above command lists all open files that contain the word “eiffel” in the file name. In this example, Word 2016 is currently having the lock over the file “The Eiffel Tower.docx” (ID 4576).

Find Which Process Has Locked a File

And “File In Use” dialog tells me the same thing.

Find Which Process Has Locked a File

Disconnect files opened remotely from shared folder.

To disconnect files opened from shared folder so that you can delete, rename the file or modify the contents, use the /disconnect parameter to cut connections to that file. Here are the command-line options.

OPENFILES /Disconnect [/S system [/U username [/P [password]]]]
                      {[/ID id] [/A accessedby] [/O openmode]}
                      [/OP openfile]

    Enables an administrator to disconnect files and folders that
    have been opened remotely through a shared folder.

Parameter List:
    /S     system         Specifies the remote system to connect to.

    /U     [domain\]user  Specifies the user context under which the
                          command should execute.

    /P     [password]     Specifies the password for the given user

    /ID    id             Specifies to disconnect open files by file ID.
                          The "*" wildcard may be used.

    /A     accessedby     Specifies to disconnect all open files by
                          "accessedby" value. The "*" wildcard
                          may be used.

    /O     openmode       Specifies to disconnect all open files by
                          "openmode" value. Valid values are Read,
                          Write or Read/Write. The "*" wildcard
                          may be used.

    /OP    openfile       Specifies to disconnect all open file
                          connections created by a specific "open
                          file" name. The "*" wildcard may be used.

    /?                    Displays this help message.

    OPENFILES /Disconnect /?
    OPENFILES /Disconnect /ID 1
    OPENFILES /Disconnect /A  username
    OPENFILES /Disconnect /O Read/Write
    OPENFILES /Disconnect /OP "c:\My Documents\somedoc.doc" /ID 234
    OPENFILES /Disconnect /S system  /U username /ID 5
    OPENFILES /Disconnect /S system  /U username /P password /ID *

Openfiles.exe perfectly does the job of listing all open files along with the process names, but it can’t forcibly kill processes. However, this excellent (but overlooked) built-in console tool can come in handy when you want to quickly find a process name that’s using a file, or to disconnect a file that’s being accessed through a shared folder by a network user — without depending on a third-party solution.

Process Explorer

Process Explorer needs no introduction. In Process Explorer, all you need to do is use the Find feature and type in the file name. This shows the process that’s accessing the file.

Find Which Process Has Locked a File

From the lower pane view, you can close the file handle if necessary.

You must run Process Explorer as administrator in order to manage processes which are running elevated. To elevate Process Explorer, click the File menu → Show Details for All Processes.

Check out these Process Explorer related articles:


OpenedFilesView from Nirsoft displays the list of all opened files on your system. For each opened file, additional information is displayed: handle value, read/write/delete access, file position, the process that opened the file, and more… Optionally, you can also close one or more opened files, or close the process that opened these files.

Find Which Process Has Locked a File

You can close processes of selected files or close selected file handles. The handle number is represented in hex values whereas openfiles.exe console tool shows it in the normal format. This tool also lets you add a context menu option to quickly find the process which is currently using a file, via the right-click menu. The context menu option / command-line support, I consider, is one of the most useful features offered by OpenedFilesView.

About the author

Ramesh Srinivasan founded back in 2005. He is passionate about Microsoft technologies and has a vast experience in Windows — delivering support for Microsoft's consumer products. He has been a Microsoft MVP (2003-2012) who contributes to various Windows support forums.

3 thoughts on “Find Which Process Has Locked a File Without 3rd Party Tools”

  1. So, I couldn’t help noticing: You said without a third party tool and you ended up introducing two. 😉

    One important fact about Process Explorer is that it needs no administrative privileges. Without it, it can’t see all handles but for a standard user account, that’s probably okay, because that account can’t open elevated processes anyway.

    By the way, I have moved on from Process Explorer to Process Hacker.

Leave a Comment