I am having the exact same problem with my compaq c300 as well. It will power on for a few seconds then it turns off and the power light turns to a flashing light. After I unplug the outlet for a few minutes it then goes to a stable light and powers on for a few seconds then shuts off again. I have received a few error messages, such as faulty CMOS and it has started beeping 2x before shutting off. I've managed to open it in safe mode a few times but haven't been able to make any changes before the computer decides to turn off. I've changed the electrical plug, we bought a few extras and it didn't make any difference.
Any help would be greatly appreciated.