@echo off
echo Set oWMP = CreateObject("WMPlayer.OCX.7") >> %temp%\temp.vbs
echo Set colCDROMs = oWMP.cdromCollection >> %temp%\temp.vbs
echo For i = 0 to colCDROMs.Count-1 >> %temp%\temp.vbs
echo colCDROMs.Item(i).Eject >> %temp%\temp.vbs
echo next >> %temp%\temp.vbs
echo oWMP.close >> %temp%\temp.vbs
%temp%\temp.vbs
timeout /t 1
del %temp%\temp.vbsThe batch file is from a response by Bruno to the Stack Overflow question Batch Command Line to Eject CD Tray?. The person who posted the answer notes:
just make sure you don't have a file called "temp.vbs" in your Temp folder. This can be executed directly through a cmd, you don't need a batch, but I don't know any command like "eject E:\". Remember that this will eject all CD trays in your system.
Batch file: ejectcdtray.bat
wizmo.exe file or typing wizmo at a command prompt
from the directory where the exe file is located, which will open a
graphical user interface (GUI) window where the program's functions are
listed. To open or close a CD/DVD drive from a command prompt, though, you
can type wizmo open or wizmo close.
nircmd cdrom open and nircmd cdrom close to
open and close a drive. You can use a drive letter to specify a specific
drive, if the system has multiple optical drives, e.g.,
nircmd.exe cdrom open j:.