Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've seen a few executables/utilities that do it, and many forums that say it is not possible to do. But is there any DOS command that I can rely on in a typical XP installation?

share|improve this question
add comment

5 Answers

up vote 2 down vote accepted

There seems to be no way using rundll or a preexisting executable.

If you have windows scripting host installed, maybe the following helps (untested, copied from another forum)

Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
colCDROMs.Item(0).Eject

Change the (0) if you have more than one drive.

share|improve this answer
    
+1 Tested and works for me on XP Pro. –  Dave Webb Sep 17 '09 at 15:30
    
FYI, every Windows has WSH installed (at least anything since 2k). –  Wedge Sep 18 '09 at 1:54
add comment

I can do better than that... Paste this into a batch file called "eject.bat":

for /F "usebackq tokens=6" %%i in (`vol %1:`) do if "" neq "%%i" rsm eject /pf%%i

You can pass any drive letter to this batch file, so you can eject any drive. You can even eject devices like iPods and USB drives.

share|improve this answer
    
Didn't work for me on my laptop's tray CD drive in XP. –  Nathaniel Dec 4 '09 at 22:22
    
Hmm, I guess it only works if there is a disk in the drive! Sorry about that. –  skypecakes Dec 8 '09 at 20:15
add comment

There is a windows API call to do it, but unfortunately not a built in command.

There is a command line tool you can download though that will do the job.

share|improve this answer
add comment

Executables do it using the mciSendCommand API. I don't think it can be done though batch as of yet.

share|improve this answer
add comment

Necro. Nir Command shortcut option "nircmdc.exe cdrom open D:" where D is your optical drive. Change icon for shortcut to something appropriate to eject.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.