TechWindows safe removal: Is it still necessary or just a relic?

Windows safe removal: Is it still necessary or just a relic?

How to check what is blocking the safe ejection of the device
How to check what is blocking the safe ejection of the device
Images source: © PxHere
Kamil J. Dudek

23 July 2024 12:52

If a USB flash drive or an external hard drive is in use when we wish to disconnect it from the computer, Windows will notify us via the safe removal button. However, it doesn’t specify which program is utilising the drive - but it is possible to check this.

The "safe removal of devices" function has already become the butt of jokes. USB flash drives rarely suffer damage during disconnection, and the warning message sounds disproportionately ominous compared to the consequences. Moreover, the system often cautions against disconnecting the USB even when nothing is using the drive. Safe removal in Windows has become so redundant that many people are unaware of this function and unplug the USB flash drive after use.

Windows has also been optimised for file queuing and cache handling to minimise losses in case of sudden disconnection. Combined with the increase in the speed of solid-state drives, the need to perform a particular operation before detaching the media has practically vanished. The last systems that unconditionally warned the user after unplugging the flash drive without warning were Windows Millennium Edition and Windows 2000. Even XP ceased doing this after one of the Service Packs.

Is it necessary?

Today, we will only receive an error message if we interrupt an unpostponed operation by unplugging or if a program tries to read from a "letter" that has just vanished. Nevertheless, safely removing older devices, platter-based drives, or media or data that we particularly wish to avoid loss/damage can be beneficial.

Today, the safe removal icon uses less pretentious terminology and describes the options for USB flash drives and drives as "ejecting the media." If the ejection is successful, no I/O operations are ongoing, the write cache is synchronized, and no programme is anticipating the presence of the media, which we can then unplug.

A native notification in the bottom right corner of the screen will announce the success of the ejection procedure. However, if a programme is still using the drive, the ejection mechanism will be denied. Windows will then display an archaic window with a format and content reminiscent of Windows 2000. Yet, it doesn’t provide information about which programme vetoed the media ejection.

Let’s use PowerShell

However, this information is available in the system log and can be extracted using Event Viewer and PowerShell. In client versions of Windows, reading this information doesn’t require administrative privileges. To discover which process vetoed the last attempt to eject the media (and which media it was), you should use the following command:

Script for checking vetoing devices
Script for checking vetoing devices© Dobreprogramy | Kamil Dudek

This way, we will obtain the program's name, PID, and the exact name of the blocked device. We can locate and disable the problematic program and try again with this information. Very often, in Windows 11, the program vetoing the ejection request is… Task Manager. Therefore, it is worth closing it before resorting to the terminal and PowerShell commands.

See also