views:

15501

answers:

8

One of my favourite tools for linux is lsof - a real swiss army knife!

Today I found myself wondering which programs on a WinXP system had a specific file open. Is there any equivalent utility to lsof? Additionally, the file in question was over a network share so I'm not sure if that complicates matters.

A: 

If you right-click on your "Computer" (or "My Computer") icon and select "Manage" from the pop-up menu, that'll take you to the Computer Management console.

In there, under System Tools\Shared Folders, you'll find "Open Files". This is probably close to what you want, but if the file is on a network share then you'd need to do the same thing on the server on which the file lives.

Matt Hamilton
+5  A: 

Try Handle. Filemon & Regmon are also great for trying to figure out what the duce program foo is doing to your system.

slipsec
+15  A: 

Use Process Explorer from the Sysinternals Suite, the Find Handle or DLL function will let you search for the process with that file open.

Jay Hofacker
Does this really answer the question? Process Explorer lets you see which files are open for a particular process/handle/dll/whatever, but that's the reverse mapping. See my answer http://stackoverflow.com/questions/15708/lsof-equivalent-for-windows#188337 to this question.
Greg Mattes
Yes it does. Click on Find Handle or Dll (or hit Ctrl-F) , type in the name of the file you are searching for, and you end up with a list of processes with that file open.
Jay Hofacker
Process Explorer has now been renamed and bundled into "Process Monitor".
Matthew McCullough
A: 

@Matt Hmm ... are you sure about this? I just checked it and it had nothing listed for opened files. Which, going by your definition, is wrong since I had many open files in two instances of VS.Net. I think this tool only lists files open on that computer from another computer on the network.

xanadont
+3  A: 

Try Unlocker.

The Unlocker site has a nifty chart (scroll down after following the link) that shows a comparison to other tools. Obviously such comparisons are usually biased since they are typically written by the tool author, but the chart at least lists the alternatives so that you can try them for yourself.

Greg Mattes
Unlocker only lists locked files, not opened files. Most Windows software locks the DLL it uses but not your documents.
Tobias
+3  A: 

the equivalent of lsof -p pid

is combined output from sysinternals handle and listdlls, ie

handle -p pid

listdlls -p pid

you can find out pid with sysinternals pslist

+1 for command-line solution
Leonel
A: 

If the file is a .dll then you can use the TaskList command line app to see whose got it open:

TaskList /M nameof.dll
Sean
A: 

Use Process Explorer to find the process id. Then use Handle to find out what files are open.

Eg handle -p

I like this approach because you are using utilities from Microsoft itself.

pushNpop