Usage example: Eject( "D:" ). Drive letter passed can be like "D" or "D:" or "D:\" or "D:\\". Only the first letter matters.

ErrorLevel will be blank when eject() was successful or contain an error text explaining what went wrong.

The other 2 parameters exist only for debug purposes. DontCheck : When true will skip MediaType check. I used this to try ejecting my C: drive and Internal DVD drive.DontEject : When true, returns the class without ejecting the drive. Useful for populating a removable drives list.

What has changed in this new version?

Win32_DiskDrive->MediaType values for a physical drive are as follows:

Unknown ; Probably a Floppy disk drive. I don't have the hardware to test

Previous version of Eject() would eject a physical drive only if Win32_DiskDrive->InterfaceTpye is USB.
A UAS drive identifies itself as USB in Windows 7 but as SCSI in Windows 8 and upwards so the old approach is now no more useful
The new rewritten version now checks Win32_DiskDrive->MediaType and proceeds with eject if media type is either Removable Media or External hard disk media
If you have a eject supported drive but the new Eject() fails, Please run

Usage example: Eject( "D:" ). Drive letter passed can be like "D" or "D:" or "D:\" or "D:\\". Only the first letter matters.

ErrorLevel:

-1 Invalid drive letter.

-2 Neither a CD/DVD drive, nor a USB Mass Storage device.

-3 Eject failed. Refer A_LastError ( range 1 - 13 ) to identify the reason. The most common will be A_LastError = 6 which isPNP_VetoOutstandingOpenThe requested operation was rejected because of outstanding open handles.