Bookmark

Donate

Subscribe

Subscribe to our RSS feed

Subscribe to our RSS feed
Email Subscription

Enter your Email ID:

Delivered by FeedBurner

Categories

Links

Know which process has locked a file

Published: May 2004
Send your feedback

Introduction

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.

Download Windows Server 2003 Resource Kit Tools

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.

// 
// TIME: 2004-05-07 19:27
// MACHINE: SUPERCOMPUTER
// BUILD: 2600
// OH version: built by: dnsrv_dev(v-smgum)
// 
// 
000003F4 msimn.exe File 025c \Documents and Settings\Ramesh\Local Settings\Application Data\Identities\{C19958F2-22F3-4C6A-9AE0-12049CE0706F}\Microsoft\Outlook Express\Inbox.dbx

000003F4 msimn.exe Mutant 0260 \BaseNamedObjects\d:_documents and settings_ramesh_local settings_application data_identities_{c19958f2-22f3-4c6a-9ae0-12049ce0706f}_microsoft_outlook express_inbox.dbx_directdbmutex

000003F4 msimn.exe Section 0264 \BaseNamedObjects\d:_documents and settings_ramesh_local settings_application data_identities_{c19958f2-22f3-4c6a-9ae0-12049ce0706f}_microsoft_outlook express_inbox.dbx_directdbshare

000003F4 msimn.exe Section 0268 \BaseNamedObjects\d:_documents and settings_ramesh_local settings_application data_identities_{c19958f2-22f3-4c6a-9ae0-12049ce0706f}_microsoft_outlook express_inbox.dbx_directdbfilemap

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.

Related article

The option "Empty Temporary Internet Files folders when browser is closed" does not work ?

Recent Posts