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 tool 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.
Related:
How do I deleted a file in use? Windows will prevent you from deleting a file that's in use by a running program. If you can't find or shut down the program a different approach is needed.
Where is my Outlook "PST" file located? Outlook's PST or Personal STore is a single file that holds your email, contacts and more. You can use Outlook itself to find the location of the file.
Article C1923 - April 11, 2004
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 AMHi 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 AMHi 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
Posted by: JM at July 29, 2008 12:01 PMJM
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 AMMy disk defrag from windows xp does not seem to working because I it says my hard drive is full. I dnt download music, movies etc just the internet.
Anyway I have reset the computer but it seems to develop another problem. it gives me some code like walpnil.exe. the computer is slower than ever. I notice this after yahoo messenger. Which i have taken off. However, it states when I try to defrag that I have no space (7%) when I need 15%. can you advise me.
Posted by: Tawrrna Wynne at December 19, 2008 3:45 PMThanks for the info. Process xp does help, but doesn't close the handle even if forced. I tried deleting a few files which were showing error but it didn't. Same is the case with unlocker, mentioned by a reader earlier. Nothing happens when i click on unlock all. Plz tell something else.
27-Mar-2009
A simple command line utility, also by the SysInternals.com folks, is Handles. Just type in
Posted by: Dan Aquinas at April 9, 2009 10:48 AMHandles {{filename_may_include_path}}
and it shows which process has the file open. Worked great for me on my local hard drive. Have not tried on a file located on a server.
(- Microsoft has bought SysInternals.com, so entering www.sysinternals.com or sister site www.wininternals.com will actually take you to Microsoft's site. -)
So far, this is a glorified task manager. This does not locate files, handles, dll or anything. I'm simply tring to find out what file is being used by what mysterious process - and this cannot locate it. I hope Microsoft didn't pay too much for this.
Posted by: Matt at April 14, 2009 6:29 AM@ Matt
Then your doing it wrong, it works fine for me. I just used it to make cfp.exe stop using a folder so I could delete it. (cfp.exe is comodo firewall, btw).
To find out what file is being used by what, you simple go to find -> "Handle or DLL..." (or just hit CTRL+F), and then type in the file or folder you want to see and hit search.
It works fine for me. It really is not that complicated....
Posted by: Core at September 25, 2009 9:03 AMThanks for the tool, but I really need it because when I attempt to download it, I've got a message telling the file already removed.
Can anyone provide me the specific file PLS ??
Thanks for the support..
Posted by: Ahmed Hawsawi at November 8, 2009 1:28 AM