This may help you out (WSH solution):
Set WMP = CreateObject("WMPlayer.ocx")
Set colCDROMS = WMP.CDROMCollection
If colCDROMS.Count > -1 Then
For i = 0 to colCDROMS.Count - 1
colCDROMS.Item(i).Eject
Next
End If
After saving script with a vbs extension, run from the command line as cscript scriptname.vbs.
Note: if WMPlayer.ocx doesn't work try using WMPlayer.ocx.7
If you have NERO, there are some commands that may be useful. Check your documentation.
Good luck. 8-)
If you need a Python solution, consider reposting this in the DOS or Programming Section.