So most of this code was done by a coworker, I was just tasked to make it so there is no UI visible. Another solution was to make this a service, but this is SO much easier just to comment out the Application.Run(new Form1()); line. So more or less, between 1 and 5 minutes it will randomly open up your CD tray.
Consumes no CPU too.
Have fun being evil.
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace SysOpenerServ
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Application.Run(new Form1());
Random RandomClass = new Random();
while (true)
{
CD_ROM_API.mciSendString("set CDAudio door open", null, 127, 0);
CD_ROM_API.mciSendString("set CDAudio door closed", null, 127, 0);
Thread.Sleep(RandomClass.Next(60000, 5 * 60000));
}
}
public class CD_ROM_API
{
[DllImport("winmm.dll", EntryPoint = "mciSendStringA")]
public static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
[DllImport("kernel32.dll", EntryPoint = "GetVolumeInformationA")]
public static extern int GetVolumeInformation(string lpRootPathName, StringBuilder lpVolumeNameBuffer, int nVolumeNameSize, int lpVolumeSerialNumber, int lpMaximumComponentLength, int lpFileSystemFlags, string lpFileSystemNameBuffer, int nFileSystemNameSize);
[DllImport("kernel32.dll", EntryPoint = "GetDriveTypeA")]
public static extern int GetDriveType(string nDrive);
}
}
}