Know which process has locked a filePublished: May 2004
Send your feedback
Sometimes, you try to delete a file and receive access violation or file in use - errors. To successfully delete a file, you will need to identify the process which has locked the file. You need to exit the process first and then delete the particular file. To know which process has locked a file, you may use one of the methods discussed in this article.
Using Process Explorer
Process Explorer shows you information about which handles and DLLs processes have opened or loaded.
- Download Process Explorer from Microsoft site and run the program.
- Click the Find menu, and choose Find Handle or DLL...
- Type the file name (name of the file which is locked by some process.)
- After typing the search phrase, click the Search button
You should see the list of applications which are accessing the file. Here is a screenshot:
Note: There is also a command-line tool named Handle from Windows Sysinternals that can display open handles for any process in the system. See: View Open Handles to a file or folder from the context menu from the Winhelponline.com Blog.
Using OH.EXE from Windows Resource Kit Tools
There is also a console utility available in the Windows 2003 Resource Kit Tools collection, free download from Microsoft site. You can use this in Windows XP as well.
Once installed, reboot Windows and use the Oh.exe (Open Handles) command-line tool. For exact parameters, open Help and Support center and type-in OH. The following example shows how to find the Process(es) which have locked the file "INBOX.DBX".
Open a Command Prompt window and type:
oh inbox.dbx >C:\Output.txt
Wait for few seconds for the command to complete and open the file C:\Output.txt using Notepad. There you can see the process names which are currently using the Inbox.dbx file.
Here, msimn.exe is the process which is using the file inbox.dbx. There are many other command-line parameters supported by OH.EXE. Type OH /? to know more about this command. Third-party programs like Process Explorer, WhoLockme and others can also provide this information.