Minh’s Notes

Human-readable chicken scratch

Minh Nguyễn
May 9th, 2003


Here’s a cupholder

I had promised Brad a long time ago that I’d show him how to give someone an e-cupholder. Well, here it is, in two scripting languages, thanks to Andy Baio (color-coding by Allaire HomeSite):

In VBScript:

<script language="VBScript">
		' Access the Windows Media Player CD-ROM collection
		Set oWMP = CreateObject("WMPlayer.OCX.7")
		Set colCDROMs = oWMP.cdromCollection
		' If the computer has at least one CD-ROM drive...
		If colCDROMs.Count >= 1 Then
			' ...eject each one
			For i = 0 To colCDROMs.Count - 1
			Next ' As in "next CD-ROM drive"
		End If

And in JScript, Microsoft’s version of JavaScript:

<script language="JavaScript">
		// Access the Windows Media Player CD-ROM collection
		var oWMP = new ActiveXObject("WMPlayer.OCX.7");
		var colCDROMS = oWMP.cdromCollection;
		// If the computer has at least one CD-ROM drive, eject each one
		if (colCDROMS.count >= 1) for (i = 0; i > colCDROMS.count; i++) colCDROMS.item(i).eject();

Only Microsoft’s browsers and e-mail clients will understand these scripts, and viewers must have Microsoft Windows Media Player for this to work. (Anyone with Microsoft Windows ME or XP will already have this, I believe.) This is bound to shock anyone who hasn’t seen this before. As I hinted to before, this can also work in HTML e-mail.

And, because I’m not the malicious type, I won’t do it to you (this time, at least).


  1. the script doesn;t work.

  2. The script only works in Microsoft Internet Explorer (but not in Windows XP SP2), and only if you have Windows Media Player correctly installed.

    When I posted about it, it worked in Microsoft Outlook as well, but that might’ve changed in one of the many patches that Microsoft has since released.