In about 5 mins I managed to create a small Python program that would work in Linux. It will ask you for the minimum and maximum time, then after a random time (between the time you gave) it will eject the disk tray.
If there is anyone more familiar with Python than myself, then they could improve the program and make it compatible with Windows, and also have the option to close the tray instead of opening it. If not, then maybe I'll do it myself when I learn more on how to do this.
If your running Linux then just copy the code below into a text editor and save it as 'eject.py', then you can run it in Python.
One way of running this is to type in a terminal 'python /home/spam/Desktop/eject.py' Change the path name as appropriate, the example assumes that the program is called 'eject.py', is located on the Desktop, and the user is called 'spam'.
I've only tested this once, so make sure that you test this before using.
eject.py wrote:import random
import time
import subprocess
#The number of minimum and maximum minutes for the program to run.
low = input("Enter minimum time (minutes): ")
high = input("Enter maximum time (minutes): ")
#Converts minutes into seconds for delay
low = low * 60
high = high * 60
#Assign the random time for the delay, from the parameters given
delay = random.randint(low, high)
#Delay the program till eject
time.sleep(delay)
#Eject the disk
subprocess.call("eject", shell=False)