Is it possible to eject a cd in a batch file on Windows XP?
12,416
Solution 1
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.
Solution 2
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.
Related videos on Youtube
Author by
prajakta
Updated on September 17, 2022Comments
-
prajakta almost 2 years
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?
-
Wedge almost 15 yearsFYI, every Windows has WSH installed (at least anything since 2k).
-
Nathaniel over 14 yearsDidn't work for me on my laptop's tray CD drive in XP.
-
stone over 14 yearsHmm, I guess it only works if there is a disk in the drive! Sorry about that.