Sometimes, common problems may arise from a dusty memory or a weak video card. Or it might be that the thermal paste between your heat sink and processor has dried up. But to be sure enough, better check your computers health by pressing F2 or Delete key to proceed to Bios Setup. Look for the PC Health or CPU Temp to see whether CPU is overheating which is the reason why computer restarts after a few minutes or so or shutdown instantly.
However, if you'd already done in the bios setup and don't find anything wrong with the CPU temperature, or in the memory card, most likely the problem is in the hard drive or HDD. Perhaps try Chkdsk Utility, it might solved the problem. If you can't use Chkdsk in that CPU, try it into another CPU but make sure to set the pin into SLAVE to avoid conflict. Automatically, it will check your hard drive for bad files sector then will try to recover or delete those bad files. After the Chkdsk, take it back to its original CPU and turn it on. it should start windows normally and if not reformat it, which is the last option (windows is corrupted).