I need to identify the CD drive and eject the tray. This is executed while booted in WinPE, so the WMP eject function is not available. This script will be used on various computer models/configurations. I'm currently using this:
For Each d in CreateObject("Scripting.FileSystemObject").Drives
CreateObject("Shell.Application").Namespace(17).ParseName("D:\").InvokeVerb("Eject")
Next
It works, but sometimes it errors and requires user interaction before it ejects. I suspect that it's because of the hardcoded D:\
drive letter, but I could be completely wrong. I need this to work without 3rd party utilities.