Waxy.org
Waxy.org is the sandbox of Andy Baio, an independent journalist and programmer living in Portland, Oregon. I 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
November 18, 2008
Bike Hero, biking a Guitar Hero level in the real world — most likely a commercial viral, and maybe even fake, but does it matter? beyond awesome
Chuck Klosterman reviews Chinese Democracy — mostly posting this just to beat Rex to it
The A.V. Club's 27 popular websites that became books — though they missed Belle de Jour, The Washingtonienne, Fucked Company, Fark, and ZUG
Speed Guitar goes to the Los Angeles County Museum of Art — every hour, on the hour, for one solid minute of metal complete with gothic arch and smoke machine
MGMT's "Kids" on the iPhone Ocarina — "the iPhone Ocarina officially replaces the recorder as the nerdiest instrument I can play"
Mena Trott responds to Valleywag article about their Disneyland vacation — my favorite was Space Mountain Snob
LIFE Magazine photo archive hosted by Google — millions of high-res photos, most never published
Amazon launches CloudFront, their pay-as-you-go CDN — very complementary with S3
November 17, 2008
John Hodgman, Jonathan Coulton, and the Long Winters perform "Tonight You Belong to Me" — "Thank you, normal-sized man."
Jerry Yang stepping down from Yahoo's CEO post — it never really fit him well, though I'll miss his e.e. cummings memos
Woman asks Apple community about an unusual iPhone glitch — no, raunchy photos don't accidentally attach themselves to outbound email
Greasemonkey script to pull WikiDashboard visualization into Wikipedia — I made a LazyWeb plea for this last week, and Paul Irish came through
Lee Byron's Fireflies, anaglyph 3D game for Mac — part of Kokoromi's Gamma 3D showcase of anaglyph games
Flickr Boundaries, tool to explore Flickr's shapefiles — read Tom Taylor's entry for more information
Cooking Mama, the Unauthorized PETA Edition — a strangely obscure target for their attention, with a petition to write to the game's publisher (via)
Boing Boing launches gaming blog, Offworld — good writing in a nice design from Brandon Boyer, former news editor of Gamasutra
"Violet" wins the Interactive Fiction Comp 2008 — play it online; glancing at the charts, it looks like Buried in Shoes was the most divisive
Trailer for J.J. Abrams' Star Trek prequel — looks surprisingly good, but I'm a sucker for origin stories; I even liked Enterprise
What would Depression 2009 look like? — Tim sums up the thought-provoking Boston Globe article
The Pirate Bay hits 25 million simultaneous peers — that's not unique people, but concurrent connections; Napster peaked at 26M users
Peter Hirschberg releases Adventure as a free iPhone app — related: Chasing Ghosts will finally be released on BitTorrent Showtime in December (via)
The Big Picture on the California wildfires — also: first-person coverage on Twitter and YouTube, like this freeway on fire and aftermath
Tim-Tams available at Target until March, first time available in the U.S. — best chocolate cookies ever, the Tim Tam Slam is a chocolaty revelation (via)
JS-909, a Javascript drum machine without Flash — through a hack, it even works in IE 6
November 14, 2008
Esquire's hosting Between, the new two-player networked game by Jason Rohrer — from the creator of Passage
"What's that buzzing noise from my BBQ?" — he thought he was killing a few bees, but ends up annihilating an entire colony (via)
November 13, 2008
Kottke explains how to embed high-quality YouTube videos — I knew how to save, link, and change the default, but the embedding hack was new to me
Web 2.0 Origami — lazyweb, please build a converter that creates folding patterns from an uploaded image
Pixar's Burn-E short on YouTube — here's an interview with the director
Valleywag folded into Gawker, all but Owen Thomas laid off — I won't miss it; they hurt a lot of good people and interesting projects in the quest for pageviews (via)

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