Download DriveCleanup for Windows 7, 8, 10, 11 - A command line tool which does what you could do manually in the Windows Device Manager or my means of DeviceCleanup
DriveCleanup is a command line tool which does what you could do manually in the Windows Device Manager or my means of DeviceCleanup, it removes all currently non-present USB Storage Devices, Disks, CDROMs, Floppies, Storage Volumes and WPD devices from the device tree. Furthermore it removes orphaned registry items related to these device types. Started with parameter -T (like test) it shows which devices it would remove.
Started with admin privileges and without a parameter it does its job without further inquiry.
To remove certain types of devices there are the parameters -U -D -C -F -V -W and -R, see DeviceCleanup.txt.
Sample to remove abandoned registry entries only:
Under x64 editions of Windows only the included x64 version works.
Admin privileges are required for actual cleanup, without it requests to switch into the test mode.
Since V1.0 it removes non-USB drives if they have a removal policy > 1 (EXPECT_ORDERLY_REMOVAL or EXPECT_SURPRISE_REMOVAL).
When started standalone it waits for a keystroke at the end. This can be skipped by param -n or by starting it minimized or hidden.
Removes from the device tree non present:
- USB hubs
- USB mass storage devices
- Disk devices
- CDROM devices
- Floppy devices
- Storage Volumes
- WPD devices