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
July 18, 2008
The Quirkbook — Rands polls Twitter for everyone's odd quirks and mildly OCD mannerisms
Jane McGonigal on Werewolf at Foo Camp 2008 — ideal strategies, a sneaky all-villager variation, and the impact of the werewolf metaphor
Google interviews the creators of WarGames — great trivia about the making of the film and its impact on tech culture
July 17, 2008
Logan Aube's Hockey Night theme — Something Awful goons tweak an online contest with funny results (via)
July 16, 2008
Sean Tevis is running for Kansas State Representative, XKCD-style — help a computer geek defeat the incumbent, a hard-right, anti-privacy Creationist; he's trying to get 3,000 to donate $9 each
How to Fake Being a Wine Snob — there might be supertasters out there, but most people are just faking it
The Economist responds to Freakonomics co-author's pasty/pastry mixup — tasty response to this original post (via)
Mike Arrington interviews Evan Williams at Foo Camp — great interview; thoughtful questions and brimming with information, without the sensationalism
Rick Trooper — The Empire rolls you.
Mocha VNC Lite, free VNC client for the iPhone — link opens in iTunes; like others, I'm hoping an SSH client is next
Annalee Newitz on Dr. Horrible's Sing Along Blog — exceeds the hype; the site's been down all day, so I just bought the season in iTunes for $3.99
July 15, 2008
The Sound of Young America Live interviews Ze Frank — strange interview, but talks about the end of The Show and current projects; see also: Jay Smooth from Ill Doctrine (via)
Defender of the favicon — staggering hack puts a playable Defender clone in your browser's 16x16 favicon; Firefox and Opera only
Twitter officially acquires Summize — search.twitter.com is now live
July 14, 2008
Deep Note, the Guitar Hero bot — it got 820k points and 98% playing Through the Fire and Flames; amazingly, some humans can still beat it, for now (via)
Unofficial RSS feed of newly-added App Store applications — until Apple adds their own, I've been keeping tabs using this
Daily Mail tries to unmask Banksy's secret identity — unconfirmed, but definitely seems likely
Trailer for August, indie drama about the dot-com bubble — the fictional dot-com is called Land Shark, but they never explain what they do (via)
Lee Byron maps walkability in San Francisco — built using Walkscore, Google Maps, and Processing
Radiohead releases dataset for House of Cards video — 370MB of CSV point data, Processing code, and a 3D viewer of Thom Yorke's face (via)
July 11, 2008
Preview video of Last.fm's iPhone app — no scrobbling from your iPod, but an outstanding streaming player (via)
Wall-E Down to Earth — fan film takes a Wall-E toy on a tour of real life
Ask the Pilot covers his recent experiences with the TSA — they wouldn't allow a pilot to carry a butter knife used for in-flight meals
Techcrunch runs the numbers on App Store's first day pre-sales — sadly, Apple removed the download counts this evening
Patton Oswalt's commencement speech at his old high school — "There Is No Them." (via)
July 10, 2008
I Eat Beats — drum sequencer built with webcam, Processing, and a bag of Skittles
Journalist examines America's rail system on an 85-hour trip from NYC to Oakland — nobody cares about the railroads anymore (via)
Bush jokes about America's pollution record to G8 world leaders — "Goodbye from the world's biggest polluter!"
iPhone 3G or Millionaire — the choice is easy
Flickr user hit by lightning while recording a rainstorm — "because you insisted, here's the unedited screaming version."

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