Home / How-to Guides / How to Hack Your CD Drive using VB Script Code

How to Hack Your CD Drive using VB Script Code

This trick is funny, and you may try it out on your friends or colleagues to surprise or panic them. Try this trick on their system without their attention and enjoy the reaction when the script starts running.

This trick forces the PC CD Drive tray to repeatedly open and close. You know how this is working, but when others see this, they will be surprised or panic and might wonder if their system got infected with some virus.

Suppose you try this on your friend’s PC in his absence; he will surely be surprised or anxious when he sees that his system is automatically opening and closing CD Tray.

Basically, it is a VB Script code program that commands the system to open and close the CD Tray running in a loop. Consequently, this continues throughout the loop unless and until the script is closed or stopped from running.

Hack your CD drive using VB Script code

Follow the below simple steps using VB Script Code:

1. Copy the below VB Script code and paste it into the notepad.

Set TI = CreateObject("WMPlayer.OCX.7" )
Set CDROMCOL = TI.cdromCollection
if CDROMCOL.Count >= 1 then
For i = 0 to CDROMCOL.Count - 1
For i = 0 to CDROMCOL.Count - 1
End If

2. Now, Save the file by any name but should end with an extension as .vbs

Hack Cd Drive

Once the File is created and saved, the file will look similar as shown in the screenshot.


3. Run the VB Script Code to Execute:

Now double-click on the .vbs file, and you should see that the system automatically opens and closes the CD tray repeatedly. To stop the script from running, simply restart the PC or stop the script from Task Manager.

Now, if you want to take this trick more further and want to annoy your friend more, load this script into the Startup folder of the system to run automatically whenever the system boots up.

Even if the system is restarted, it will again automatically run when the system is booting up. However, once you are over with the prank, make sure you remove the script from the startup folder, or else the system will always keep running the script when the system boots up.

Follow the below steps to copy the script in the startup folder:

1. Open Run Dialog Box, and paste the below directory path to the Run dialog box to open the Startup folder.

%userprofile%\Start Menu\Programs\Startup\

2. Now, Copy the Script vbs file and paste it into the startup folder.

How to Stop the VB Script from Running:

For Windows XP:

To stop the script, open task manager (Ctrl + Alt + Del), now go to process, and find the name with “wscript.exe, select wscript.exe, and Click on End Process.

hack drive

The message box will pop up asking, “Are you sure you want to terminate the process” Click on Yes.

hack cd drive

For Windows 10 (All later versions of Windows XP) :

Open Task Manager by right-clicking on Taskbar and selecting “Task Manager”. Navigate to Details Tab. Select “wscript.exe” and click on “End Task”. When popup confirmation will display, select “End Process”.

End WS Script process in windows 10

It will terminate the script program and eventually stop CD Tray from opening and closing the CD tray door. Furthermore, remove it from the startup folder if copied in the startup folder; else, it will load automatically on every windows boot.

Note: This trick works great on Desktop PC because the cd tray can close itself, but the cd tray does not close by itself on the laptop. Hence, it may not be much interesting if running on a laptop device.

For the Latest Updates on Techie Inspire, Subscribe to Techie Inspire

About Roshan Karkera

Roshan Karkera a.k.a. k.roshan. Blogger by passion and software engineer by profession. He believes in sharing knowledge, which made him to start his own blog. He is very much keen & passionate about new technology & Science. If you'd like to connect with him, follow at Google plus or Twitter.


  1. Thanks this is great
    its working

  2. cool i love this
    i will sure try on my friend pc
    Thanks Dj roshan

  3. i named it cdvirus.vbs Notice NAMED IT i cant save it as .vbs cause i can only choose .txt or all files
    plz help me

  4. @anatheras
    Its very simple
    just type any name with extension .vbs Remove that .txt written there and type xyz.vbs
    And SAVE…
    Its done

  5. I love it!! and it realy works 😀


  6. Cool Trick Mast Hai

  7. how do you put a time on it so it opens exactly every 3 minutes

    • @dwoodward

      You can use WScript.Sleep 180000 in the code to run exactly every 3 min. Below is the complete code.

      Set TI = CreateObject(“WMPlayer.OCX.7” )
      Set CDROM = TI.cdromCollection
      if CDROM.Count >= 1 then
      For i = 0 to CDROM.Count – 1
      WScript.Sleep 180000
      Next ‘ CDTRAY
      End If

Leave a Reply

Your email address will not be published.