Created
June 4, 2015 15:23
-
-
Save drasive/e5f8b4799cfeb18ca50d to your computer and use it in GitHub Desktop.
Ejects and inserts a computers optical drives in random intervals.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Variables | |
Dim waitTimeForStartMinimum | |
Dim waitTimeForStartMaximum | |
Dim waitTimeBetweenEjectAndInsertMinimum | |
Dim waitTimeBetweenEjectAndInsertMaximum | |
Dim waitTimeBetweenInsertAndEjectMinimum | |
Dim waitTimeBetweenInsertAndEjectMaximum | |
' Configuration | |
waitTimeForStartMinimum = 7 * 1000 * 60 | |
waitTimeForStartMaximum = 15 * 1000 * 60 | |
waitTimeBetweenEjectAndInsertMinimum = 5 * 1000 | |
waitTimeBetweenEjectAndInsertMaximum = 15 * 1000 | |
waitTimeBetweenInsertAndEjectMinimum = 2 * 1000 * 60 | |
waitTimeBetweenInsertAndEjectMaximum = 4 * 1000 * 60 | |
' Initialize CD-ROM drives | |
Set oWMP = CreateObject("WMPlayer.OCX.7") | |
Set CDRomDrives = oWMP.cdromCollection | |
' Exit if no CD-ROM drives are present | |
If CDRomDrives.Count < 1 Then | |
WScript.Quit | |
End if | |
' Wait for start | |
wscript.sleep(random(waitTimeForStartMinimum, waitTimeForStartMaximum)) | |
do | |
' Eject drives | |
For CDRomDrive = 0 to CDRomDrives.Count -1 | |
CDRomDrives.Item(CDRomDrive).Eject | |
Next | |
' Wait for insert | |
wscript.sleep(random(waitTimeBetweenEjectAndInsertMinimum, waitTimeBetweenEjectAndInsertMaximum)) | |
' Insert drives | |
For CDRomDrive = 0 to CDRomDrives.Count -1 | |
CDRomDrives.Item(CDRomDrive).Eject | |
Next | |
' Wait for next eject | |
wscript.sleep(random(waitTimeBetweenInsertAndEjectMinimum, waitTimeBetweenInsertAndEjectMaximum)) | |
loop | |
' Helpers | |
Function random(minimum, maximum) | |
random = Int((maximum-minimum+1)*Rnd+minimum) | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment