Powertoys: File in use - who has my file locked?

Created on 16 May 2019  Â·  14Comments  Â·  Source: microsoft/PowerToys

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.

Idea-New PowerToy

Most helpful comment

I think a program to see what program is using that file is a good solution. Force closing/deleting may cause undefined behavior.

All 14 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!

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...

Raised a request to OS folks and they just closed it saying it's too hard for them

OMG really? Too difficult for developers?
"nil volentibus arduum"

Raised a request to OS folks and they just closed it saying it's too hard for them

OMG really? Too difficult for developers?
"nil volentibus arduum"

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.

Detailed discussion here.

@crutkas
based on Raymond comment, this is not something we want to add to PT.

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.

Explorer already does this when it can find out.
image

@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.

Was this page helpful?
0 / 5 - 0 ratings