I'm assuming the machine you're working with has a "chance" of boot. I'm also assuming that once the machine gets onto the operating system, there's also a chance of randomly shutting down. If I am assuming right...
1.) Check the motherboard for anything metal that could be touching it. Anything conductive could be shorting on and off. :S
2.) Adjust the heatsink for a tighter fit, or try a new one.
3.) Inspect the processor for apparent burns or other damage.
4.) The RAM could be faulty, make sure you're only using one stick when you try to boot up the computer. Try out each stick, however many there may be.
5.) The motherboard may have sustained electrical damage and is unstable.
Having this problem on my machine before, I found the heatsink to be the culprit. Hopefully I've given some info that would help, let me know what the conditions are like after the machine boots into the operating system.
The heatsink may be the problem. One time when it started normally, i was putting the power supply back into the case and found I had one wire betwee the fan and the section around the processor. When it does start, it runs normal and hasn't shut down.