Sometimes you unmount a drive on Windows and you get an error message saying that the drive is still in use even when you know that you’ve closed all open files on the drive. This post will show you how to list open file handles on a Windows drive so you can close them and properly unmount your device. Before I knew this I would just yank out my memory stick or would be forced to shut down my PC in order to safely unmount.
When you get an error message like that shown in the above picture that means that a process is still accessing a file on the drive you’re trying to unmount. If you’ve closed every suspect process and you still get this error message, the easiest thing to do is close the process that’s still accessing your drive.
One way to do this is using Sysinternals Process Explorer or the open-source Process Hacker. In either program type Ctrl+F which will open a dialog as shown below:
In this example, I’ve entered “h:” as the name of the drive that I’m trying to unmount. The program will then search for all processes that contain a handle to a file in this drive. Then I can terminate all processes that show up in the results box. Usually it is safe to terminate all the processes, but use your judgement to ensure you don’t kill a vital process.
Those who prefer to use the command line can also check out Handle which is available as part of the Sysinternals suite or can be downloaded and used on it’s own. You can find process ids using pslist. In some situations, listdlls might also come in handy.
The *nix equivalent of these programs is lsof and it works like a charm. Hopefully this tidbit will help make your Windows use less stressful.