Ask Leo!

How can I find out who is using a "file in use"?

Home » Windows » Windows Oddities

Summary: Windows will often report that a file is in use without telling you what program is using it. Process Explorer can tell you.

How can I find out who is using a "file in use"?

The scenario typically looks like this: you want to delete, move, perhaps rename a file, or maybe even just use it in another application and you get a message that you can't. The message indicates that another application is using the file.

Great. "What application?" you ask.

It wouldn't be that hard for Windows to tell you, but since it doesn't you'll need to do a little investigatory work yourself. Fortunately there's a free tool.

When I'm faced with this situation, I grab my copy of SysInternals procexp.exe a very nifty took that does exactly what we need here (and a whole lot more). Procexp is, in a nutshell, task manager on steroids. I've referenced it in several answers as a great tool to use to see what's running on your system. However it's also a great tool to see who's got that file open.

Let's assume I'm trying to find out who has my mail folder open. In my case that's the file "personal.pst". I'll run procexp, and select Find, Find Handle.... (Every object such as an open file is identified by a unique number called a "handle" - procexp searches across all those objects, not just the files.) I'll enter in personal.pst and procexp will respond something much like this:

OUTLOOK.EXE        2956   C:\xfer\MAIL\personal.pst
OUTLOOK.EXE        2956   C:\xfer\MAIL\personal.pst
OUTLOOK.EXE        2956   C:\xfer\MAIL\personal.pst

Sure enough, as we might expect in this case, Outlook has the file open.

If you're networked there's another situation that might need an additional step. For example, I keep my email archives on a server so we'll look on that server to see who has this years archives, 2004.pst, open. On the server I'll use procexp as before to see who has 2004.pst open and the results will look much like this:

System             4      C:\admin\mail\2004.pst

OK, now that didn't help much. "System" is just that; the operating system. In this case it's probably the networking component of the system that manages file access from remote users. So who's the remote user opening the file?

This one's easy, and the tools are already on your machine. On the server right-click on My Computer, then select Manage, expand Shared Folders, and click on Open Files. There you'll see a list of files on the server that are currently opened by other computers on your network. That'll tell you the User who has the file open. You'll need to then click on Sessions to see what computer(s) that user is connecting from. In my case, 2004.pst is in use by my laptop. So I'll head over to my laptop, once again run procexp, and this time search for 2004.pst there. The results:

OUTLOOK.EXE        2956   \Device\LanmanRedirector\leo\mail\2004.pst
OUTLOOK.EXE        2956   \Device\LanmanRedirector\leo\mail\2004.pst
OUTLOOK.EXE        2956   \Device\LanmanRedirector\leo\mail\2004.pst

Sure enough, Outlook running on my laptop has 2004.pst open (three times, again - that's just an Outlook artifact). In this case you can see it's via something called the "LanmanRedirector" which is the part of Windows' networking software on my laptop that handles requests for files that are located across the network.

So for simple, "who's using this file?" procexp is a one-stop answer. If the network is involved it might take an additional step or two.

But the answers are definitely out there.

Article 181 | Posted April 11, 2004

Recent Comments
37 Comments

hey leo
ive been looking for 3 days for a solution to deleting an empty folder that may be full or write protected or in use. its in documents and settings and is a regular folder. i re named it and tried deleting with various software and no luck.
please email me back you can


regards
faisal

Posted by: Faisal Al-Mayahi at April 17, 2007 2:08 PM

SOME TIMES when Im ON MY COMPUTER i SEE THAT SOME ONE ELSE IS USEING MY MSN. HOW CAN I FIND OUT WHO IT IS

Posted by: raymond at July 27, 2007 8:41 AM

Other solutions...

The Windows Server 2003 Resource Toolkit comes with the console app OH.exe (open handles).

http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en


WhoLockMe is a freeware GUI app.

http://www.dr-hoiby.com/WhoLockMe/index.php

Posted by: brsrkr at September 7, 2007 10:58 AM

unlocker is the simplest (and therefore the best) utility I've found for deleting files and folders when that annoying "in use" message appears - you don't even have to kill the process to unlock the file. And it's free! http://ccollomb.free.fr/unlocker/

Posted by: Rod Nolan at March 18, 2008 6:40 PM

I have a trojan on my computer that various anti virus programs can detect but not delete. it is a windows system32 dll file that can't be deleted manually. Is there anyway to remove it. Also the link for SysInternals just takes me to massive microsoft site

Posted by: Eamann at May 23, 2008 7:27 AM

Hi Leo, I'm trying to rename a file that is on one of the servers, but it gives this damn message, but I'm not authorized to send applications in the servers to do this analysis, so, here is the question. There is some way to discover what program is using the file, or a software that remotely do this job??

Thanks for your attention.

Posted by: rafaelpdl at July 17, 2008 10:43 AM

Hi Leo,

I am dealing with an Ad-Ware virus detected by Avast. It appears that the infected files are generated on the fly by.

For instance Avast reports a virus detection for
C:\WINDOWS\system32\xxywVOfC.dll
Even if I delete this file it comes back at a later time. I also have performed a boot time complete virus scan on the disk and the virus remains.

I have run find handle using ProcessExplorer for this file and it reports the following:
winlogon.exe 1688 DLL C:\WINDOWS\system32\xxywVOfC.dll
winlogon.exe 1688 handle C:\WINDOWS\system32\xxywVOfC.dll
Explorer.exe 3140 DLL C:\WINDOWS\system32\xxywVOfC.dll

Is there a way I can find which process is generating these files?
Could it be that the virus is within either winlogon.exe or Explorer.exe?

Thanks
JM

Posted by: JM at July 29, 2008 12:01 PM

Thanks for the procexp.exe tip. It helped me track down a pesky WordPerfect problem, when some of my most used files were giving me the "must be read-only or in use" error. When procexp.exe told me it was WordPerfect that had the files open, I realized that I had two WordPerfect processes open (one must have failed days ago...)

Ta da! Problem solved by opening the Windows Task Manager and killing the duplicate WordPerfect process.

Posted by: Barbara Feldman at September 14, 2008 9:11 AM

How can i find out whether a file is open or is in use by some application in Linux using c language ?

Posted by: yogi at September 25, 2008 2:27 AM

Great tip! Saved me lots of headache!

Posted by: Sonofaforester at October 6, 2008 10:34 AM

Post a comment on "How can I find out who is using a "file in use"?":






(Email Address will not be published.)

Remember Me?

By popular demand...
my tip jar
Cuppa Joe
Buy Leo a Latte!

(you may use HTML tags for style)

New!

RSS feed Subscribe to the RSS Feed specifically for comments on this article.

Before commenting, please...

Please wait. Your comment is being processed ...


Ask Your Question:


ask-leo.com
Web

Stay Informed

Weekly Newsletter

Archives

By Category
By Date

Advertisers

Advertise on Ask Leo!

««   »»

Question? - Ask Leo!
Who is Leo?
Link to Leo!

Terms, Conditions & Privacy