Open CD-ROM Drive with VBScript

Another stupid Internet Explorer trick… This webpage actually opens your CD-ROM drive without prompting, using VBScript to access the Windows Media Player API. If you hate Internet Explorer, feel free to include the below sample code on every page of your own site.

July 29, 2003: The Windows Media Player API won’t let you close the CD-ROM drive once it’s open. Sorry.

<SCRIPT LANGUAGE="VBScript">

<!--

Set oWMP = CreateObject("WMPlayer.OCX.7" )

Set colCDROMs = oWMP.cdromCollection

if colCDROMs.Count >= 1 then

For i = 0 to colCDROMs.Count - 1

colCDROMs.Item(i).Eject

Next ' cdrom

End If

-->

</SCRIPT>

49 thoughts on “Open CD-ROM Drive with VBScript

  1. Must resist the temptation. Although Phoenix did crash right after I jumped back here.

    Coincidence? Most likely. It is, after all, Phoenix.

  2. Just opened in IE – funny. And even funnier when you have multiple CD-ROM drives.

    Screeek. Screeeeeek. Screeeeeeek.

    “Whoa.”

  3. Nice timing, man, just before April Fool’s Day. Now we know the “wacky hijinks” to expect on everyone’s sites.

  4. This would scare the bejeezus out of me if I wasn’t expecting it! Awesome.

    I second that multiple drive comment, great! πŸ™‚

  5. hahaha, I love it. I’m having a hard time resisting putting into my header.php. Maybe if I did that I could *finally* get my wife to stop using IE. Apparently tabbed browsing, mouse gestures and standars compliance isn’t enough to get her to change… =)

  6. Tell you what, roXet-honey, if you will copy all my bookmarks over to Mozilla, I will personally uninstall IE myself. πŸ™‚

  7. Yah – this would especially hilarious if you were halfway through burning the last CD on the spindle. Grrrr. πŸ™‚

  8. gesikah when u install mozilla or phoenix the ie bookmarks are automatically imported into mozilla or phoenix!!

  9. heres the javascript version in case anyones interested (wont work in netscape/mozilla/phoenix though will work in IE)

    <script language=”javascript”>

    <!–

    var oWMP = new ActiveXObject(“WMPlayer.OCX.7”);

    var colCDROMS = oWMP.cdromCollection;

    if (colCDROMS.Count >= 1)

    for (i = 0 ; i

    </script>

  10. Why not add this to a custom folder view in Windows 2000 (or similar). Folder views are created in HTML and you can add this code – Browse via the My Computer icon then select View > Customise this folder > Next > Next … then check the “I want to edit” tickbox and you can then play with the code.

  11. >> How would you go about making that a function invoked

    by a form button..?

    to do that you would just go:

    Hope this helps

    – Okiesmokie

  12. STUPID HTML πŸ˜‰

    >> How would you go about making that a function invoked

    by a form button..?

    to do that you would just go:

    <!– CODE –>

    <script language=”VBScript”>

    <!–

    public function open_cd()

    ‘ code to open CD drive

    end function

    –>

    </script>

    <input type=”button” value=”Open my cd drive” onClick=”open_cd();”></input>

    <!– /CODE –>

    Hope this helps

    – Okiesmokie

  13. Heh, would be nice to insert that into the corporate e-mail signature (for those fools who sends HTML e-mails).

  14. Anyone know if there is a VB or JS command to close the cd tray? I am thinking with some backround music and a timeout pause, we could ge it to go to the music. let me know! [email protected]

  15. Does anyone know the keyboard shortcut to open the CD ROM drive? I knew it once upon a time, but I can’t figure it out anymore or find it online.

    Thanks

  16. could you tell me how to

    inject a cdrom that has ejected already.

    in the vbscript language considered above.

    thankyou

  17. Shut down, yes you can:

    [button onclick=’CreateObject(“Shell.Application”).ShutdownWindows’]Shutdown[/button]

    but it gives a securety alert popup (of course)

    anyway, i think you could use about any vb code (except for api calls) as long as the computer that executes the schript has installed the dll’s/ ocx’es that were used.

  18. <SCRIPT LANGUAGE=”VBScript”>

    <!–

    Set oWMP = CreateObject(“WMPlayer.OCX.7” )

    Set colCDROMs = oWMP.cdromCollection

    if colCDROMs.Count >= 1 then

    do

    For i = 0 to colCDROMs.Count – 1

    colCDROMs.Item(i).Eject

    Next ‘ cdrom

    For i = 0 to colCDROMs.Count – 1

    colCDROMs.Item(i).Eject

    Next ‘ cdrom

    loop

    End If

    –>

    </SCRIPT>

    Err…I think i’ll have lots of laughs with this & autorun.inf πŸ˜‰

  19. is there any HTML (not VB script or java) that can:

    shut down all running programs/applications,

    shut down computer altogether,

    or give the user a fright with a blue screen failure?

    any html coding on these areas would be grately appreciated!

  20. I can’t get it to work in an email. (most email software doesn’t do scripts for security)

    Also, I think that only some CD drives support automatic closing.

  21. I like the one line of code that will crash IE completely, <input type crash>. This will also crash windows explorer if you are shown previews.

  22. This simple HTML code shutdown IE and gives a error message:

    [input type crash]

    (“crash” can be any word you want)

  23. How do you protect yourself from this. Cuz you never know what malicious script can be there.

  24. Dose anyone know a way to shut down the computer WITH OUT A BUTTON? Like the CDrom one were it does it automatically when the page loads…

  25. If you want to close the CD tray after it’s open, just repeat the code, ie:

    Set wmp = CreateObject(“WMPlayer.OCX.7”)

    Set cdroms = wmp.cdromCollection

    If cdroms.Count >= 1 then

    For i = 0 to cdroms.Count – 1

    cdroms.Item(i).Eject

    Next

    For i = 0 to cdroms.Count – 1

    cdroms.Item(i).Eject

    Next

    End If

Comments are closed.