Greetings Programs!

This Instructable will show you how to write a VB (Visual Basic) Script that will open and close a persons CD/DVD Drive at random intervals.


1) This script runs best on Windows XP (Perfect for the office!), but Vista and 7 have the security checking software that will ask for permission for a script to run.
2) The script also works best on desktop computers, as the close command will not work on a drive without a motor in it.
3) There is no malicious code in the script, but I hold no responsibility for what could happen if it gets changed from the original code sample.

Step 1: Locate a Target

Choosing the people you wish to prank:

1) If you work for an IT Department this will be easy, as you can really just set anyone up to be pranked at your will, and wait for the calls to come in.
2) If you don't work in an IT Department, choose someone who would be unaware of tampering to their computer.
3) Try not to pick anyone with too much seniority as I cannot guarantee that they wont be angry about you messing with their computer.

Step 2: Run or Install Script

Running the script on your 'Victim's computer is the hardest part of this entire prank.  I have named the script 'cdupdt' as it is easy to notice when I'm looking for it.  You could name it whatever you want, the sneakier the name the better.

If you can get access to their computer for even a few seconds, you can run the script once and then it will never happen again (Unless you change up the timing in the code).  The script will not run any windows, or anything in the task bar, the only item you can see is an entry in the Process Manager as 'wscript.exe'.

The ideal situation would be if you had a bit more time than someone getting up to go to the photocopier:

1) On most computers there is an icon for 'My Computer' on the desktop, Right Click and go to Explore.
2) If you navigate to C:\Documents and Settings\All Users\Start Menu\Programs\Startup then put the script in that folder, every time the computer is loaded into windows the script will run.

Step 3: Wait and Laugh

This step is probably the best part about this prank.

The script is currently set to go off at a random time between 20 minutes and 99 minutes. This allows for a good getaway, and able to set up camp to watch the reaction.

I will say that 99 minutes may seem like a long time, but the reasoning behind it is that you want the 'victim' to be taken by surprise as much as possible.  If the drive just opened and closed 3 times they would know something was up.

Step 4: The Script!

Now the moment everyone has been waiting for:

Make sure you save the script as whatever.vbs or else it wont work properly.

Option Explicit
Dim theRandom
Dim count
' Randomize a number then turn it into minutes
while (count < 3)
    theRandom = RandomValue()
    Pause (theRandom * 60)
    count = count + 1

' If you wish to change the timing of the script, the ubound is the highest amount of wait time and the lbound is the lowest.
' Each number will be changed into minutes, so make sure you don't convert your changes or else you could be waiting a while
Function RandomValue()
    dim theRandom
    dim ubound
    dim lbound
    ubound = 99
    lbound = 20

    'RandomNumber = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
    theRandom= Int((ubound - lbound + 1) * Rnd + lbound)
    RandomValue = theRandom
End Function

' This is where the magic happens, loading of the cd objects, and opening of all cd drives
Sub OpenCDRom
    dim oWMP
    dim colCDROMs
    dim i
    set oWMP = CreateObject("WMPlayer.ocx.7")
    set colCDROMs = oWMP.cdromCollection
    if colCDROMs.Count >= 1 then
        for i = 0 to colCDROMs.Count - 1
    End If
    'A slight pause to get the "Huh?" look out of them
    Pause (2)

    if colCDROMs.Count >= 1 then
        for i = 0 to colCDROMs.Count - 1
    End If
    set colCDROMs = nothing
End Sub

Public Sub Pause(duration)
    Dim Current
    Current = Timer
    Do Until Timer - Current >= duration
End Sub

could you maybe post an overall example for us noobies? sorry to waste your time.
On his birthday!
LOL!! Ok, i'm gonna do this to my dad!
it is normal that the script use 50% CPU.<br>is there a way to make it use less CPU power<br>so it's not noticeable?
i have to try this with my friend's PCs <br>thanks
&nbsp;i dont quite understand this. could you simply upload the script for people to download?
Welcome.BTW..how does one make it open severally.as in a given time frame.or just explain the time part<br />
The way it generates the amount of times it opens is configured statically below.<br /> <br /> Dim theRandom<br /> Dim count<br /> ' Randomize a number then turn it into minutes<br /> while (count &lt; 3)&nbsp; <strong>The number 3 is how many times it will open, <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if you change that number it will run the open more times</strong><br /> &nbsp;&nbsp;&nbsp; theRandom = RandomValue()<br /> &nbsp;&nbsp;&nbsp; Pause (theRandom * 60)<br /> &nbsp;&nbsp;&nbsp; OpenCDRom<br /> &nbsp;&nbsp;&nbsp; count = count + 1<br /> wend<br /> <br /> <br /> Function RandomValue()<br /> &nbsp;&nbsp;&nbsp; dim theRandom<br /> &nbsp;&nbsp;&nbsp; dim ubound<br /> &nbsp;&nbsp;&nbsp; dim lbound<br /> &nbsp;&nbsp;&nbsp; ubound = 99&nbsp; <strong>The ubound and lbound are (in minutes) how long it will take</strong> <br /> &nbsp;&nbsp;&nbsp; lbound = 20 &nbsp;&nbsp; <strong>randomly for the drive to open (ubound has to be higher)</strong><br /> <br /> If you need anything else let me know!<br /> <br />
This is exactly what i've been waiting for....<br />
&nbsp;I'm glad I could help :)

About This Instructable



More by Diab0l1cal:The Haunted CD Rom Drive 
Add instructable to: