In case anyone is interested, there's a powertoy called file locksmith that will show what's using it and let you kill it: https://learn.microsoft.com/en-us/windows/powertoys/file-locksmith
post
"Hey Linux, can you just delete this file please?"
"Sure thing bud, a program is using it, it's ok, I will just unlink the inode anyway, the program can still access it until it closes the file"
This is honestly one of my favorite features of the linux filesystem. As a dev it makes things like replacing and hot-reloading plugins way easier.
It turns out you can kind of get the same functionality on Windows if you rename the open file and place the new one with the original name, but it's a bit of a hack.
Windows won't let you rename a file that's being used either.
Yeah, super annoying. In Linux you can rename or move it and the app using it doesn't care.
Although having the option of listing the app using a file so I can kill the app would also be really nice to have. I'm sure Linux has something for that too, but I don't know what it is.
Iβm sure Linux has something for that too, but I donβt know what it is
fuser
I can't remember the other program that'll do it.
But there's another one that'll list all the processes using a file.
Tip of my tongue fuck.
You can use PowerToys on windows to see what app is using a particular file
That's actually a thing, but I'm not entirely sure in which cases. Probably only for services and not apps, but I've done that myself where deleting a file was impossible, but renaming it and deleting it worked.
Maybe it's only possible in certain cases, but I can tell you for certain it's possible with running exe's and loaded dll's. I have a CMake step on Windows that does this rename hack so my builds don't fail if I still have the app running.
It turns out you can kind of get the same functionality on Windows if you rename the open file and place the new one with the original name, but it's a bit of a hack.
Only if you don't have OneDrive working. In that case, you have to wait for it to sync or it won't go through.
Anytime I have an issue at work where I can't change or delete a file, it's a 50/50 split between Excel and OneDrive being the cause
the mpv player does that too for the cache folder. It's configurable and documented
Hmm. So are the blocks freed up for overwriting on file close, then?
Yes. On Linux/Unix you don't delete the file, you just delete it's name, which is merely a link to the actual file. That's also the reason why the syscalls name is actually unlink and not delete. As soon as there's nothing pointing to a file anymore, it is deleted.
As long as a process holds a file handle, there's still a reference to said file, so it won't be deleted. That saved me once, when I accidentally deleted a file I wanted to keep: As there still was some process keeping it alive, I could just go to /proc/[process id]/fd/[file descriptor id] and copy it to a safe location.
Good to know, and helps me understand code dealing with filesystems a little better. I'm curious how the kernel keeps track of it all, just a counter maybe?
On Linux/Unix you donβt delete the file, you just delete itβs name, which is merely a link to the actual file.
Is that different on other systems?
I don't know how NTFS does it, but on FAT filesystems the directory table contains the filename along with all the other file metadata (access rights, creation date, size, etc). Only the list of sectors containing the actual data is separate. That means that you can't have two filenames for the same file on FAT filesystems.
If you want to learn more about this, the data structure UNIX filesystems use, and FAT filesystems lack is called inode.
Me: I've close the program, now please delete the file
Windows: ok, give me half an hour, it's not easy to delete 500 MB
... And the file is back open somehow. Only now the program throws an error when Windows launches, yet still leeches resources.
Here's an incredibly animated chart of how poorly I'm doing. Note that I seem to throttle the operation every 5 seconds or so.
Explanation? No, no. Haha. No. We don't do anything like that.
Oh you think because you closed the program it's released the file? Think again chump!
Hey Linux, sudo rm -rf /
sigh I'm surrounded by idiots.
"Sure thing boss" you fucking moron.
back in the XP days, I used a software called "Unlocker" just for this problem. It probably still exists, I don't know, because since Windows 7, the easiest way to find out what process locks a file is to open Resource Monitor (Start search: resmon) and on the CPU tab, using the "Associated handles" list, you can search for the file name and see the process in question (and kill it).
So yeah, Resource Monitor is a useful tool on Windows.
There's a collection of free little utilities called Microsoft PowerToys, including the file unlocker thing. Why would they not include these into base kit Windows is beyond me.
not including PowerToys inside basic package is a fucking choice. Win11 is literally unusable without it in many aspects.
I would argue windows 11 is pretty much unusable regardless
I suspect it's in line with big tech policies to coddle end users instead of educating or trusting them. I assert (particularly since the introduction of the iPhone in 2007) that learned helplessness is built into the game plan.
100%! Like with major setups and upgrades now just being throbbing circles and a pulsing blue light with the creepy "We're doing stuff on your behalf behind this screen." messaging.
I say computers (and the Internet) are for anybody, but not everybody. Learning to use a tool will always be a requirement of useful tools.
There used to be a time when most people using a computer implicitly understood how files and folders worked, for instance. But now even such a simple abstraction is considered advanced esoteric lost arcana.
I'm deeply saddened by how the tech industry has deliberately pushed understanding backwards so hard in order to foster more obedient consumers.
It's actually wild to see how many people who were at the very least, young adults during the computer boom of the late 80's/early 90's, can't handle anything without a touch screen and don't comprehend email.
Ignorance is sold as the future.
Sysinternals is also a great tool. Not as vital for the average user though.
Why would they not include these into base kit Windows is beyond me.
Some of them felt a bit buggy when I last time used Windows, maybe they aren't fully ready to ship (like Samsung's Good Lock apps?). And most features didn't do quite what I imagined it to do, but that's probably a "me problem".
That's a fair point, but, let's be honest, the built in Windows features often have the same issues
Not recently copilot and AI implementation has made the OS beyond shitty recently and a lot of broken shit. That's why I need to move to Linux they're basically sinking their ship with broken AI code.
I feel like it's a testing ground for new features for them, but not sure why some aren't yet integrated. Best guess: the PowerToys team has less red tape and checks to go through than the Windows team to allow for faster iteration, but that means that integrating the features wouldn't be just the click of a button since they'd have to adapt it to fit the Windows style. But this is just a wild guess.
I think you're right on the money. There seems to be a component of enticing power users to stick with Windows as well. The app is still "in beta" despite the first release being in 1996 (!). I had to look that up, because I'd only heard about it in the early windows 10 days.
Because they want to include things with ads now - i.e. the ad-supported Outlook in the place of Mail.
The bugs and horribly slow hardware that caused the locks in NT/XP have slowly disappeared, by win 10, I rarely had any files I couldn't delete if I, worst case, made explorer reload. It used to happent o be every other day in the late 90s
What gets me is when I'm not allowed to remove an external drive. Deleting a file can be delayed until later but here I am with a physical object that I need to detach from my computer and first I need to play hide and seek with the OS.
If this happens often, you can disable write caching for that drive. It'll feel slightly slower (since it's actually operating at the speed of the hardware instead of caching operations in RAM and gradually writing them to disk in the background), but you'll be able to remove the drive almost instantly.
I used to find it had something to do with the explorer thumbnailer finishing up but sort of not letting go. It would happen if I had pictures or videos on the USB drive, and if I got the error I could go to another folder like my documents, drag a picture into another folder, go look at the pretty new thumbnail, then I could remove the USB drive because the thumbnailer was 'parked' back on the C drive. Sounds like I'm making it up but I swear it worked.
Shouldn't that happen automatically if the drive is identified as removable? And the real solution should be to tell the OS that it's removable?
I was having terrible performance problems in Windows a while back, and it turned out it had marked every drive as removable and the write cache was filling up due to an extremely slow external HDD, causing even the internal SSDs to grind to a halt until the buffer was flushed whenever a large amounts of writes were made to the HDD. Which, since the external drive was used for backups and large Steam games, was almost every other day.
And that removable objectβs filesystem is probably the most shit, unjournalled filesystem in the world so youβre actually fucked if it becomes corrupted by removing it early.
And if you move the drive between operating systems you're very limited in what filesystems you can use because Windows is very limited in what filesystems it can use. So you can't just pick a more robust filesystem.
Some Windows apps do handle it properly. For example, if you have an archive open in 7-zip and try to delete it, Windows Explorer should correctly tell you that it's open in 7-Zip. I'm not sure why it doesn't work that way for all apps.
Windows doesn't even tell you if Explorer itself has a folder open... how the hell does 7-Zip do it?
Shout out to my MVP Notepad++ telling the file has been deleted by another process and letting me decide if I want to keep it open anyway. Fantastic feature. I literally could not do my job without its ability to leave log files alone so they can be written to while I'm still browsing them.
Meanwhile on Linux: /boot successfully deleted
I once deleted /dev/null Do not recommend. Youβd be surprised how much of the system needs it.
I once deleted /dev/urandom. I didn't want uncertainty in my life.
Well, I was on for a surprise.
How? I could've sworn it wasn't even a "real" file. I thought the file system just had special rules for interacting with that name.
Lol yea, but it would have been such a small tweak with big big QoL improvements LMAO
You can use process explorer, it even has option to act as a replacement for task manager.
Edit: https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer
There is nothing in windows that's a small tweak.
Changing anything has implications to a banking business Joe somewhere, who's program depends on the original feature working as it does, or one of the 16 layers of code is simply tangled in a way such change would require cascade of rewrites.
I've read articles about various developments: working with regex registry*, or just adding a control panel option, and it's an absolute nightmare.
changing it too much carries high risks
This is such a Windows way of thinking. Why does every other OS constantly change and evolve but Windows is like βcanβt touch this code from a quarter century ago?β
Because any time anything changes in Windows, people bitch about it.
I dare say, that 90% of all companies in Europe and US, use Windows. And lots of companies relies heavily on software built 20-30 years ago. Microsoft knows this.
That's why they are very reluctant to "touch that piece of code from a quarter century ago" because there's probably a lot of software that would break without it. Software their target audience need.
You ever worked in like a real job? Have you ever seen the amount of legacy code that depends on some other legacy piece of shit which itself depends on...?
It's absolutely maddening, being there, diagnosing the issue and absolutely having no way to do anything about it because no time, not allowed, no need if it ain't broken, our customers rely on this specific version, etc.
It's not a Windows way of thinking, it's what every single one of the businesses I've worked with for the last twenty or so years think like. And changing shit is incredibly expensive.
On my Windows 10 laptop, Task Manager virtually freezes the whole system for about four seconds when you switch tabs.
The current UI is very different to the original UI though.
opening the task manager with a shotgun cocking sound
Shame...

top 96 comments