-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File in use - who has my file locked? #114
Comments
I think a program to see what program is using that file is a good solution. Force closing/deleting may cause undefined behavior. |
True, but force closing user started processes COULD work. |
I have been looking for this for so many years. Raised a request to OS folks and they just closed it saying it's too hard for them. A power toy for this saves us from restarting computer to unlock a file from whoever has a lock on it! |
http://www.emptyloop.com/unlocker/ for unlocker, |
In looking at this, it sees to be that this is one of those things that really should be in the base OS. I'd say 60% of the time that I hit a need for this, it's with an installer. That front would be best improved with an API, and the installer world isn't likely to take a dependency on PT. Also think of just deleting a file from Explorer in general - you'd want to see it right there. While I'd love for PT to implement this for the cases it does cover...I do feel it's really the wrong place for a solution in this case. I'm not sure how we lobby the Windows team to add it in though... |
OMG really? Too difficult for developers? |
Well, not as easy as messing with start menu background color😂 I just use Sysinternals Process Explorer to figure out who holds the lock these days. |
Force-closing handles creates data corruption, because the handle you forced closed will get reused for something else, and then the original code will now be writing to the wrong file. |
@crutkas |
What about showing the process that has the open file? |
@lukebarone, I think that is a better approach and ironically what i named this issue in the roadmap doc. |
@oldnewthings, from my experience, I always get vagueness, never something targeted. A great example is at times trying to delete my bin folder and explorer is like ¯_(ツ)_/¯ do you want to skip |
Would this also be possible for USB hard drives and USB thumb/flash drives? Sometimes, when I want to disconnect an external drive, it tells me it's in use. |
Not sure of the right terminology, but if it's a process with a visible window, perhaps PT should offer to bring it to the foreground. |
For me this is one of the 2 most common use cases and need for this rather than going through the pain and in-efficiency of using Process Explorer. |
For me the real value of this PT proposal is to quickly identify unexpected (often background) processes locking a file.
|
I definitely agree that this would be a really useful addition to PowerToys - and definitely if it could have more "intelligence" than other tools in terms of what are safe processes to close and what are not (and showing what processes are locking the file) would be a big benefit. Personally I use IObit Unlocker and have found this to be pretty reliable, especially for situations when programs have crashed and left threads open blocking files (and sometime stopping you restarting the program), or those programs that just don't release them properly when you would expect them to --- for example Outlook when you close a PST file that you had opened (e.g. an archive file that you wanted to find something in) :-( |
This is a common gripe with just about every windows user, and would certainly be a terrific idea for a power toy. Someone above mentioned Explorer already does this, but failed to note it does so in a highly unreliable fashion - sometimes you do indeed get a hint. Most times, you do not. Many power users have already found solutions to this issue on their own, and while stand-alone programs make it easy to blindly get the job done, Process Explorer can find each process that has a stubborn handle and can often inform how safe it is to close them individually. For example sometimes a browser might lock a file, and I can just restart the browser or close the tab hosted by that process, instead of forcing the handle. Incredibly versatile tool, should be part of any power user's kit. |
The proposed PowerToy would just use RmRegisterResources, which is the same API that Explorer uses, so it would fail in the same way. If you have a reproducible scenario where RmRegisterResources fails to identify the process that is holding a file handle open, please let me know so I can report it to the RmRegisterResources owners. |
@oldnewthing If I understand correctly, applications would be expected to call Repro steps:
Expected outcome: "This folder is in use by cmd.exe [PID]" It doesn't tell you that cmd.exe is responsible for this. Whereas if you use for example Process Hacker, it successfully finds that it's in use by cmd.exe |
On the other hand, if you open PowerShell and type So it gives you a descriptive error message if the resource in use is a file handle, but not if it's a working directory. |
Okay, the "current directory" one I can believe, but the fact that people complain about this so rampantly tells me that there's some other file-based scenario that's slipping through the cracks. RmRegisterResources is supposed to work for files without any cooperation from the file handle opener. |
CRUTKAS:
changing this based on a comment by @oldnewthing.
Tell me WHO has the file locked, not just drop the handle. Dropping the handle can have bad side effects
ORIGINAL POST
When deleting files, sometimes files are locked for no apparent (to the user) reason coughthumbs.dbcough. The program "Unlocker" could be used, but it really should be a power toy with smarter integration to the OS, deleting thumbs.db is harmless, deleting ntoskrnl.exe could be bad.
So a toy for smartly dropping open file handles could be useful.
The text was updated successfully, but these errors were encountered: