Every once in a while, I get an error that I can’t disconnect my USB drive because there’s a file handle opened by another program. Unfortunately, Windows doesn’t help much beyond that, and it’s left up to the user to figure out which app and shut it down. In some cases, the problem persists even after shutting down all of the open apps and you have to resort to looking through the process list in Task Manager. Of course, you can always log off or restart the computer, but there has to be an easier way.
In Linux, there’s a nifty little utility called lsof. The name of the utility, lsof, is short for List Open Files, and it does just that. It displays a current list of open files, including details such as the name of the program using the file, it’s process ID, the user running the process, and more. The output can be a bit daunting for an inexperienced user, but it’s a very useful tool. Combined with the power of grep, a user can quickly identify what files a process has open, or what process has a particular file open. Very handy for dealing with misbehaving programs.
Similar tools exist for Windows, but most of them are commercial tools, not available for free use. There are free utilities out there, but I hadn’t found any that gave me the power I wanted. That is, until today.
I stumbled across a nifty tool called Process Explorer. Funnily enough, it’s actually a Microsoft tool, though they seem to have acquired it by purchasing SysInternals. Regardless, it’s a very powerful utility, and came in quite handy for solving this particular problem.
In short, I had opened a link in Firefox by clicking on it in Thunderbird. After closing Thunderbird, I tried to un-mount my USB drive, where I have Portable Thunderbird installed, but I received an error that a file was still open. Apparently Firefox was the culprit, and closing it released the handle.
The SysInternals page on Microsoft’s TechNet site list a whole host of utilities for debugging and monitoring Windows systems. These can be fairly dangerous in the hands of the inexperienced, but for those of us who know what we’re doing, these tools can be invaluable. I’m quite happy I stumbled across these. The closed nature of Windows can be extremely frustrating at times as I cannot figure out what’s going on. I’m definitely still a Linux user at heart, but these tools make using Windows a tad more bearable.