The first time this happened the system was idling and I just happened to be close enough to hear it go silent suddenly. I turned it back on and it booted the BIOS, but while it was loading Windows 7, the system rebooted itself and repeated the process. It could boot in safe mode, but whenever I attempted to do certain actions, it would reboot. My first assumption was hard drive failure, so I put the drive in another working PC to test (i did not try booting off of it). To my surprise, the HDD had seemingly no errors, with all the data still intact. After I backed up important data, I reformatted the HDD and put it back into my PC. I installed a fresh copy of Win 7 Pro 64x, and everything went back to normal for about 2 weeks. When my computer randomly shut off this time I was in the middle of a game of BF3. Turned the system back on and the same problem started to happen again.
My only guesses to what might be causing this are the HDD overheating or a flawed motherboard. Possibly a bad PSU, considering it's just barely enough wattage for my graphics card. I haven't upgraded the PC in a while, so it's not like I recently changed anything. I've had the PC for about 3 years.
Specs: The computer
I've added a GTX 550 TI, upgraded the RAM to 12GB, and upgraded the PSU to some off brand 400W(I think).