≡ Menu

How to eject and close CD Drive using VBscript

After reading labnol post, I felt why only Unix and why not windows. I did some search over internet and finally could able to tailer this script.

It works fine if you have only one CD-Drive. If you have multiple CD drives, then explore the options of the Object I am using in this script.

Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set ArrCDROM = oWMP.cdromCollection
while (1)
wscript.sleep 3000
ArrCDROM.Item(0).Eject
wscript.sleep 3000
ArrCDROM.Item(0).Eject
wend

Write in comments section if you need any more clarity.

Happy learning..,
Sitaram Pamarthi

Tags: Vbscript for ejecting CD-Drive, CD-Drive eject command, eject CD drive from command prompt.

Comments on this entry are closed.

  • zimonic December 8, 2012, 12:59 pm

    Hi, thanks for this post! However, this does not work on my Windows 7 laptop with Windows Media Player uninstalled from Control Panel. So how to do both eject and close without the OCX?