See open file handles windows




















Its hard to keep up with its display if you watch it live, it does so quickly. Now owned by Microsoft but originally by Sysinternals. Sign up to join this community.

The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Learn more. How do you find what process is holding a file open in Windows? Ask Question. Asked 12 years, 8 months ago. Active 3 months ago. Viewed k times. Any suggestions on how to find the culprit? Improve this question. Alan Fleming 73 8 8 bronze badges. You would think that after all this time, the Windows guys would give us a way to do this easily from within Explorer. I wonder why this hasn't happened?

I find that Explorer is very often the problem process that is holding onto a file for no obvious reason. I know this doesn't help you much, but I think I remembered that this was a planned feature of the next Windows release after vista and server. Issue still exists in Windows Randomly got to this question on unrelated search.

When I stumble upon this problem with something holding the file, it's often explorer. Now you need to restart your explorer. Show 1 more comment. Active Oldest Votes.

Improve this answer. Eddie Eddie You can close the handle, but keep in mind, you're pulling the rug out from under an application, results will be unpredictable at best.

Walden: Absolutely. When this happens on a file you need to delete, you have the choice of forcing the handle closed, or rebooting. So far, having done this dozens of times, I have suffered no ill effect. As with any advanced tool, use with caution and judgment. Closing the handles can cause the app to re-use the handle on another file, causing corruption - see Jeff's answer below: serverfault.

For explorer, btw, hold ctrl-shift and right-click a blank area of the start menu, and you'll get "Exit Explorer" - ps, not quite Jeff's answer..

It should be noted that ProcessExplorer must be run as Administrator or it may not able to see files open by system processes. Show 12 more comments. Svish Svish 6, 14 14 gold badges 34 34 silver badges 45 45 bronze badges. It's worth noting that it can be hard to find this program on Windows 8 - a search for 'resmon. Kylotan, Stop wasting time searching. Just run resmon directly from cmd — Pacerier.

Pacerier: Nice. I'm not used to things being in the Windows path. Show 9 more comments. Community Bot 1. Mark Sowul Mark Sowul 1, 1 1 gold badge 10 10 silver badges 14 14 bronze badges.

It seems strange to me that Windows would immediately re-use the number of a closed handle, rather than continuing to increment the number and only wrapping around when necessary.

That would at least greatly reduce the chances of this problem happening. RichVel Terminating the culprit process is probably better than a complete reboot. DmitryGrigoryev - good point, and in fact I already mentioned that here — RichVel. This is a very important warning, but doesn't answer the question How do you find what process is holding a file open in Windows?

Show 4 more comments. John Fouhy John Fouhy 1, 7 7 silver badges 4 4 bronze badges. When a file is opened by a process using the CreateFile function, a file handle is associated with it until either the process terminates or the handle is closed using the CloseHandle function.

The file handle is used to identify the file in many function calls. Each file handle and file object is generally unique to each process that opens a file—the only exceptions to this are when a file handle held by a process is duplicated, or when a child process inherits the file handles of the parent process.

In these situations, these file handles are unique, but see a single, shared file object. See DuplicateHandle for more information on duplicating file handles held by processes. Note that while the file handles are typically private to a process, the file data that the file handles point to is not.

At first glance, it looks perfect for your needs! You can even wrap this within a PowerShell function to ease the querying and disconnecting of files. This objects list is what actually maintains the list of handles that are in use and enables openfiles to query that information. The downside to turning this feature on is that there is a slight performance hit, which depending on your system, may not be worth the utility of using this tool.

Using that information, you can then disconnect a file to unlock it. Due to the performance hit you may incur with enabling the maintain objects list capability, it might not be worthwhile for your needs. Because of that, other solutions may be needed. Sysinternals is known for the many useful and nearly essential IT tools that they make. Some time ago, Sysinternals was acquired by Microsoft, and you can download and use these well-supported tools for yourself.

Conveniently, there is an application named handles that provides exactly what you are looking for! First, youneed to download the application, unzip the files, and put the executables in a location that your Path environmental variable has included. By doing so, you can easily reference the application wherever you need it. Using a simple query for open files, you can see that you get a lot of results truncated for readability.

You seem to get what you want—at least a way to find out what files are being used—and you can test them using your file locked code from before. But how do you make this easier to use?

The following code reads each process and retrieves just the locked files.



0コメント

  • 1000 / 1000