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 3, 2009
Kevin Kelly's Death Clock in Futurama — this might seem morbid to some, but I find it inspiring
July 2, 2009
Paul Lamere's Coolness Index — are female singers uncool?
Kickstarter's Big Day — 13 projects ended on July 1, raising an average 188% of their goals
Anil Dash on Malcolm Gladwell's criticism of Chris Anderson's Free — I read through Gladwell's New Yorker piece twice, and the arguments seem petty and off base
72-year-old retired boxer beats up knife-wielding knucklehead — the inane Facebook photos make this story even more delicious
July 1, 2009
Pez sues Burlingame Museum of Pez for copyright infringement — so disappointing
RIAA wins lawsuit against Usenet.com — judge rules Betamax case doesn't apply; every other Usenet provider is next
June 30, 2009
EveryBlock releases source code — it was a requirement of their funding from the Knight Foundation
Hype Machine detects cheating on charts, names names — one of the bands responds in the comments and gets schooled by Anthony (via)
Ze Frank on black, white, and shades of green — I'm loving this series
China bans gold farming, real-world sale of virtual goods — Eurogamer estimates 1 million Chinese gold farmers with worldwide trade worth more than US$10 billion annually (via)
The Pirate Bay sold to publicly-traded Swedish gaming company — Brokep's statement is delusional; being acquired will almost certainly kill the site
Michael Rubin's "Droidmaker" book now available for free download! — authoritative 518-page history of Lucasfilm, the creation of Pixar, and much more (via)
June 29, 2009
Jason Rohrer interviewed about "selling out" to make iPhone and ad games — he recently switched from free, open-source games; also, EA claims Spielberg's LMNO isn't cancelled
Nedroid's Cosby Experiment — view all 190 Cosbys
How the NYT kept their reporter's Taliban kidnapping off Wikipedia for seven months — they collaborated with Jimmy Wales directly to freeze the entry; NPR asks if it was ethical (via)
David Fincher may direct Facebook film, adapted by Aaron Sorkin — possibly starring Michael Cera or Shia LaBeouf as Zuckerberg; this sounds familiar (via)
Quarrygirl's undercover investigation of non-vegan ingredients used at L.A.-area vegan restaurants — outstanding blog reporting, with industrial food testing from 17 different restaurants and research into suppliers
June 28, 2009
James Barnett's oil paintings of landscapes from video games — looking at the paintings, I felt like I'd actually visited those locations in real-life (via)
WSJ interviews Brenda Brathwaite about "Train," a board game about the Holocaust — not all games need to be fun (via)
June 27, 2009
How Rob Manuel accidentally started a Michael Jackson moonwalk flashmob — I'm in London right now, and I've seen several massive vigils and tributes on the streets (via)
Top teams join forces to win Netflix Prize — check the leaderboard for the first score to break the 10% improvement threshold (via)
Wired on the success of Nike+ — backstory on how it works and the Hawthorne effect; simply measuring something can change its behavior (via)
June 26, 2009
Imeem to delete all user-added photos and videos, with five days' notice — with no way to back up videos at all (via)
Shnabubula's chiptune tribute to Michael Jackson — also: Virt's incredible VRC6 cover of Thriller
June 25, 2009
Metafilter user highlights 20 years of Elvis Costello's "adenoidal" voice in the NYT — Stephen Holden and Neil Strauss have a limited musical vocabulary (via)
June 24, 2009
Flashterm, free telnet client for the web — I love his gallery page, full of BBSes
Peter Nitsch's Flash port of AA-Lib, image-to-ASCII art library — the demo is fun; also: his real-time video conversion to ASCII (via)
Simon Willison's four lessons from the Guardian's journalism crowdsourcing experiment — they deliberately made it game-like to encourage participation (via)
June 22, 2009
Ze Frank's That Makes Me Think Of... — first of a series on Time.com, reminiscent of The Show (via)

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