by

How to eject cd drive using windows code

Nice prank to play on your friends. This will eject the CD-drives in the local computer every 2 minutes.

Copy the code below into a text file. Rename it to .vbs and execute.

'get hold of the object who controls the windows media player
set mediaPlayerManager = CreateObject("WMPlayer.OCX.7")

'make a list of all CD-Roms installed in the computer
set CdROMCollection = mediaPlayerManager.cdromCollection

' put the process to sleep for 10 minutes
' just enough time to sound like unexpected when it runs
wscript.sleep 6000000

' performs an eternal loop (or until the user restart the machine or kill the process)
do
'if there is at least 1 cd-rom in the machine,

if CdROMCollection.Count >= 1 then
'go through all the cd-roms found and eject each one of them
For i=0 to CdROMCollection.Count-1
CdROMCollection.Item(i).Eject
Next
End If

' put the process to sleep for 2 minutes
wscript.sleep 120000

'return to the beginning of the loop and repeat
loop




No comments:

Post a Comment