Waxy.org
Waxy.org is the sandbox of Andy Baio, a journalist/programmer living in Portland, Oregon. I'm the CTO of Kickstarter, created Upcoming.org, and some other stuff too.

Contact Me: log@waxy.org or waxpancake on AIM

Open CD-ROM Drive with VBScript

Posted Mar 27, 2003
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 Comments (Add Yours)

Mar 27, 2003
8:26 PM  
Shannon wrote:

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

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


Mar 27, 2003
8:28 PM  
Shannon wrote:

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

Screeek. Screeeeeek. Screeeeeeek.

"Whoa."


Mar 27, 2003
9:32 PM  
Anil wrote:

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


Mar 28, 2003
12:43 AM  
Mary wrote:

This would scare the bejeezus out of me if I wasn't expecting it! Awesome.
I second that multiple drive comment, great! :)


Mar 28, 2003
6:57 AM  
roXet wrote:

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


Mar 28, 2003
3:35 PM  
gesikah wrote:

Tell you what, roXet-honey, if you will copy all my bookmarks over to Mozilla, I will personally uninstall IE myself. :-)


Mar 29, 2003
5:25 PM  
chas. wrote:

Yah - this would especially hilarious if you were halfway through burning the last CD on the spindle. Grrrr. :-)


Mar 30, 2003
5:20 PM  
CIAwallst wrote:

How would you go about making that a function invoked
by a form button..?


Apr 1, 2003
9:00 AM  
steve wrote:

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


Apr 1, 2003
10:16 AM  
Anonymous wrote:

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 colCDROMS.Item(i).Eject();
-->
</script>


Apr 1, 2003
2:02 PM  
Karsten wrote:

Dosn't work with MSIE 5 here. Wait, do I need to have this awkward WMP7 installed? Who does that, anyway? :P


Apr 3, 2003
3:58 AM  
笪远锋 wrote:

Very Good!


Apr 3, 2003
7:39 AM  
Anonymous wrote:

Send this to e-mail heh


Apr 6, 2003
12:24 PM  
Tony wrote:

This is so cool!!! you guys have anything else like that?


Apr 8, 2003
12:01 PM  
paulo wrote:

does n e one know how to get it to work in an e-mail


Apr 14, 2003
10:03 PM  
Elspeth Gordie wrote:

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.


Apr 18, 2003
8:34 PM  
Okiesmokie wrote:

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


Apr 18, 2003
8:35 PM  
Okiesmokie wrote:

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


Apr 23, 2003
1:47 PM  
bob wrote:



Apr 24, 2003
7:56 PM  
Alex wrote:

Is there a code i can put on my site that will close the cd-rom drive?


Apr 25, 2003
3:46 AM  
mrPhonig wrote:

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


Apr 25, 2003
3:09 PM  
deggz wrote:

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! cstanley@accessus.net


Apr 29, 2003
10:05 PM  
ifan wrote:

How to close the CDROM?


May 4, 2003
5:53 AM  
Alex wrote:

mmm know how 2 do that in ASP.net
but how come that code doesnt work for wmp9


May 6, 2003
1:13 PM  
Mhairi wrote:

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


May 12, 2003
9:08 AM  
jac wrote:

could you tell me how to
inject a cdrom that has ejected already.
in the vbscript language considered above.

thankyou


May 14, 2003
12:54 PM  
Robert wrote:

Hello

are there any more scripts like these,
shut down or what ever!!


May 17, 2003
3:33 PM  
Steven wrote:

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.


May 21, 2003
3:25 PM  
David wrote:

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


May 22, 2003
2:00 PM  
Erik wrote:

I can't close it again by opening it. Will someone help me out here? :)


May 28, 2003
3:54 PM  
Alan bebe wrote:

Heh. Way ta go, Microsoft! :)


Jun 12, 2003
4:23 AM  
Matt wrote:

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!


Jun 14, 2003
5:00 PM  
Terry Price wrote:

luv it ive been looking for ages 4 a script dat does dat!! well done


Jun 30, 2003
7:48 AM  
Arinful Ambia wrote:

very nice


Jul 2, 2003
3:26 AM  
claire wrote:

vey good


Jul 5, 2003
3:30 PM  
mcslipmatt wrote:

nice script people lol i put it on my site


Jul 7, 2003
3:29 PM  
thomas wrote:

hello,
can you close the cd drive whit an html code?


Jul 9, 2003
9:32 AM  
anon wrote:

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.


Jul 12, 2003
11:47 AM  
Ian wrote:

Cool, but it would be better if the cd draw closed as well....any suggestions??


Jul 15, 2003
6:33 AM  
Bezzer wrote:

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.


Jul 19, 2003
7:37 AM  
Loretns wrote:

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

[input type crash]

("crash" can be any word you want)


Jul 19, 2003
12:15 PM  
MBBM wrote:

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


Jul 19, 2003
12:28 PM  
Andy Baio wrote:

That one's easy! Switch to a better browser, either Firebird in Windows or Safari in OS X.


Jul 29, 2003
3:46 PM  
Aki wrote:

Cool Code!
How do you close it?


Aug 5, 2003
2:31 PM  
s3v1n wrote:

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


Aug 11, 2003
10:23 AM  
Joel wrote:

you can close the cd drive by callin eject consecutively


Aug 12, 2003
12:08 PM  
Meh wrote:

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


Aug 14, 2003
5:08 AM  
Robert wrote:

Where abouts do i place this script?


Aug 14, 2003
7:40 AM  
Andy Baio wrote:

In a webpage on your site. I'm closing this thread because of excessive script kiddie dumbness.


 
Waxy Links
Ads via The Deck
March 18, 2010
Newspaper Club designs, prints, distributes overnight newspaper at SXSW — I was lucky enough to grab one of the hand-numbered issues
March 17, 2010
Crowdsourced demographic study of Chatroulette — the info was gathered by Hacker News users
March 16, 2010
Progress Wars — countless hours of fun
March 15, 2010
Piano Improvisation on Chat Roulette — amazing how much creativity the site's inspiring (via)
March 12, 2010
8-Bit Austin — I think I'll use this map to get to Datapop 2010
Spritely, jQuery plugin for sprite and background animation — see also: gameQuery
March 11, 2010
Trololololololo Shreds — some context (via)
Preview of Sword & Sworcery EP for the iPhone — looks unlike anything I've ever seen
Sitby.us — essential iPhone-optimized site for SXSWi session planning
Danc on the release of Ribbon Hero — turning Microsoft Office into a game, with competition against your friends (via)
March 10, 2010
"Play" by David Kaplan and Eric Zimmerman — avatars as Russian nested dolls (via)
Chatroulette Map — I think I'd rather not know, thanks (via)
Steamshovel Harry — not sure how I missed this one last year, metagaming with music by Brad Sucks
El Fin Del Mundo by Alberto González Vázquez — there's so much I love about this, I can't quantify it all (via)
March 9, 2010
Wired Reread, blogging the best ads from '90s-era Wired — also, the complete SPIN archives are on Google Books
Academy Award Winning Movie Trailer — related: McSweeney's categories for the meta-awards (via)
Chris Parnell and Andy Samberg perform Lazy Sunday live — for the first time, backed by The Roots
Adam Savage's pursuit of the perfect Blade Runner gun replica — related: his quest for the perfect replica Maltese Falcon and dodo skeleton
The Panic Status Board — the instant feedback made work more game-like
March 8, 2010
Valve ports game library and Steam service to Mac — Portal 2 will be released for Mac simultaneously with PC, along with "all of our future games"
Maciej Ceglowski on the discovery, loss, and rediscovery of the cure for scurvy — fascinating story of bad science and the unintended effects of new information
March 7, 2010
8-Bit NYC, Brett Camper's videogame map of New York — he's using Kickstarter to expand to 15 other cities worldwide
Sleep Is Death, Jason Rohrer's new conversational two-player game — watch the slideshow for details; I just wish it was on the web instead
Obama appoints Edward Tufte to advise on stimulus transparency — "Maybe I'll learn something."
PS22 Chorus sings Phoenix's Lisztomania — I love how expressive they are
Echo Nest and SCHED's guide to SXSW Music — very nicely done, uses Echo Nest's recommendation engine
GameInformer's Portal 2 exclusive cover story — scans, since it's not on GameInformer's site yet; Valve hired the TAG: The Power of Paint team right out of Digipen
March 5, 2010
Cal Henderson on gaming probability in World of Warcraft — he's collected 118 pets, some of which only drop 1 in 10,000 attempts
March 4, 2010
LiveJournal rewrites outbound links with affiliate codes — looks like the regex was a bit greedy
NYT on Chinese "human-flesh search engines" — very similar to the H+ article on the topic from last year

Andy Baio lives here. Some rights reserved, for your pleasure.