2015-07-14

Solved: cannot eject USB device: "This device is currently in use."

Millions of people all over the planet continuously have this problem: they try to eject their USB drive so as to avoid data loss, but windows does not allow them.  Which is very frustrating, because whatever reasons windows thinks it has for not allowing the removal should have lower priority than the user's explicitly stated direct wish to remove the damned thing!

Anyway, suggestions for solutions abound on the interwebz.  Here are some that I found with a quick search:

1.  Put your computer to sleep.  When going to sleep, Windows flushes all buffers to all devices, so while the computer is asleep, it is safe to remove the device.  The problem with this approach is that I don't want to have to put my bloody computer to sleep each time I want to take a USB device out.

2. Use SysInternals Process Explorer to search for the drive name, find which process has a handle open on the drive, and terminate it.  The problem is that drive names are only one a letter and a colon, a search for "D:" may yield thousands of handles from several dozen processes, all of which are unrelated to your drive "D".  Unfortunately, Process Explorer does not offer any option to search for a whole word only.  Another problem is that this approach hardly ever works.  Apparently, there are ways in which devices can be locked which do not show in Process Explorer.  Even if you remember to launch it as Administrator.

3. Select "Quick removal" policy as opposed to "Better performance" policy in the drive properties. The problem with this is that it is not really a solution: we generally do specifically want the better performance, and we are willing to sacrifice quick removal for it, accepting slow removal instead. But this issue is not one of slow vs. fast removal, it is about not being allowed to remove your device at all, ever!

Here is the solution which worked for me, after the above failed:

4. Make sure that the drive, or any folders in it, are not shared on the network!  (Use "NET SHARE" on the command prompt to quickly find out what you are sharing.)

3 comments:

  1. Well, that's helpful, except I want to share the drive on the network most of the time!

    ReplyDelete
  2. Yes, of course. You can either stop sharing the drive from the "host" computer (the one on which the drive physically resides,) or from each "client" computer (that makes use of the shared drive.) Right-click on the drive, and there should be sharing-related options. They differ depending on whether you are on the host or on one of the clients, on your version of windows, and also depending on what is your configuration, (whether you are in a domain, a workgroup, or a homegroup and whether you have "advanced sharing" enabled or not,) but the options are there.

    ReplyDelete