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
November 20, 2009
Regretsy gets a book deal — the anonymous author turned out to be April Winchell, collector of audio oddities
Google Chrome OS Demo — a world without a local filesystem and apps; also, the Chrome UI concept video (via)
Patrick Moberg's Internet Vices — funny, Tumblr feels more like beer than wine to me
Charlotte Gainsbourg and Beck's "Heaven Can Wait" — Keith Schofield's surreal video and insane treatment were inspired by FFFFOUND and Reddit, but maybe too explicitly (via)
November 19, 2009
YouTube adds machine-translated automatic captions — starting with some partner channels, but auto-timing is available to everyone today
Microsoft tries to patent Edward Tufte's sparklines — they were recently added to Excel
Leonard Lin's Retweet Avatars for Greasemonkey — a subtle change, but a big improvement
Web-ops god John Allspaw leaves Flickr to join Etsy — he's the last of the original Ludicorp team to go (via)
November 18, 2009
Laptop Steering Wheel Desk — don't miss the product photos
Interview with Ralph Eggleston, Pixar's production designer on WALL-E — from last February, but new to me; I didn't know the Axiom had three passenger classes
NSFW: Animated pixel-art video for Flair's "Trucker's Delight" — warning: very offensive and sexist, but the attention to 16-bit detail by director Jérémie Perin is incredible
NY Observer on Anil Dash's new government 2.0 incubator project — Expert Labs debuted at Web 2.0 today, funded with a $500k grant from the MacArthur Foundation
November 17, 2009
Google's Dan Morrill explains how the Droid autofocus breaks every 24.5 days — this gets second-place for quirkiest Android bug (via)
Conan O'Brien and Andy Richter on Zach Galifianakis' Between Two Ferns — his style of comedy usually makes me uncomfortable, but this made me laugh
The Pirate Bay shuts down their tracker for good — they're switching to DHT instead
November 16, 2009
How Darren at Link Machine Go found Belle de Jour's identity five years ago — Brooke was part of the early UK blog scene
ICU64, real-time visualization of Commodore 64 memory — the developer also posted videos of Paradroid and Boulder Dash (via)
Russell Davies on pretending and "barely games" — his SAP prototype looks like great ambient fun (via)
NYT Magazine on the indie gaming movement — nothing new here, but good overview with a wonderful closing anecdote from Cactus
Tim O'Reilly on the pending War for the Web — "more than that, it's a war against the web as an interoperable platform"
November 14, 2009
Jason Scott rounds up Geocities' top 10 most popular MIDI files — along with a torrent with 51,000 MIDIs rescued by Archive Team
Matt Haughey on the discovery of his brain tumor, treatment, and the Internet's response — there were about 1,000 #mathowielove tweets in 24 hours
Belle de Jour reveals herself after six year of anonymity — only six people in the world knew, she only told her parents yesterday (via)
Paul F. Tompkins debates comedy ethics with Improv Everywhere's Charlie Todd — great discussion, and it's hard not to see where both are coming from (via)
November 13, 2009
Rogue Amoeba stops iPhone app development after App Store idiocy — I'm with Marco, the only fix is allowing external apps, but it's unlikely (via)
Numb3rs on IRC — "Luckily, I speak l33t."
Prank War 8: The Skydiving Prank — hard to say if life-threatening situations are funnier than public humiliation
301 Works, Internet Archive works to preserve URL shortener data — the shorteners will provide regular backups and hand over data on closure, though TinyURL's conspicuously missing
November 12, 2009
Quizipedia — simple game with trivia scraped from Wikipedia entries
Kill Screen, funding a new art magazine about videogames — sounds like the English analogue of Amusement I was hoping for

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