This PowerShell script will disable the ability to eject specific hardware devices in Windows.
I personally use it to prevent accidentally ejecting the USB drive that I am booting a persistent Windows installation from.
$DeviceSubKeys = @('USB\VID_1234&PID_9876\...')
$CM_DEVCAP_EJECTSUPPORTED = 0x2
$CM_DEVCAP_REMOVABLE = 0x4