Could the Eject button on the front of the drive be Sticking?
Check to see if there's any interference between the button and the front bezel of the drive...
If not, then remove the IDE cable from the drive, and try powering up again... If it still opens/closes by itself, then I'd suspect you have a defective CDRW drive...
Another possibility could be a build up of dust and other crud inside the drive shorting out parts or even preventing the eject button from coming out all the way and then making interment contact.
If the eject button is not binding on the front Bezel and a clean out doesn't cure the problem the only answer is to replace the drive. As you didn't mention the Make, Model or age of the drive it is very hard to help you any more than that.
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
virrus