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>

Comments

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

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

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

    Screeek. Screeeeeek. Screeeeeeek.

    “Whoa.”

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

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

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

    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… =)

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

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

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

    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>

    Dosn’t work with MSIE 5 here. Wait, do I need to have this awkward WMP7 installed? Who does that, anyway? πŸ˜›

    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.

    >> 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

    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

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

    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]

    mmm know how 2 do that in ASP.net

    but how come that code doesnt work for wmp9

    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

    could you tell me how to

    inject a cdrom that has ejected already.

    in the vbscript language considered above.

    thankyou

    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.

    <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 πŸ˜‰

    I can’t close it again by opening it. Will someone help me out here? πŸ™‚

    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!

    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.

    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.

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

    [input type crash]

    (“crash” can be any word you want)

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

    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…

    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.