So about a week back, I was using my computer and it suddenly said shutting down. I then thought maybe it was doing an update, so I attempted to press the power button once off. However, before I could do so It restarted of its own accord, and then failed to actually boot for more than a handful of seconds over and over again. Eventually it did work and I used it for hours on end, and it repeated the shutting down issue eventually. While I had the computer working for that short stint, I tried to look at temperatures for the CPU and it showed 25 at boot, the Memtest86 I ran showed no memory issues after 4 passes, and the HP scan for hardware issues showed nothing. Totally dejected, I then tried to change my PSU to no avail, then did a little trial and error with the RAM chips, the GPU, and the Harddrive, once again...... to no avail. I attempted to get a response on Reddit and was met with utterly obvious suggestions, so I hope I can get more success here!
Symptoms like you're having is probably the Power Supply, Ram card, Motherboard, CPU, graphics card or a bad peripheral on a USB cable (or other cable that supplies power).
1. Disconnect all cables from your PC except for your monitor, keyboard and mouse. Sounds drastic but remember that USB cables supply +5 volts so a bad peripheral on a USB cable can cause problems. Run bare bones while you troubleshoot.
2. It's very rarely the CPU so you can put that on the end of the list.
3. If you tested with a "known good" power supply, then that's off the list.
4. Running memory tests ONLY confirm that a RAM card is bad if the test fails. If the test never fails, it can still be a bad RAM card. Assuming that you have two RAM cards for dual channel RAM, remove one and run with only one RAM card in the primary slot (usually the second one from the CPU but check your motherboard manual). If the problem persists, then swap the RAM cards and run again with only one RAM card. If the problem still persists, then it's not RAM unless both cards are bad which is probably not the case unless you had a power flux that damaged both RAM cards.
5. If you have a graphics card and your motherboard has graphics ports on it, then remove the graphics card and connect your monitor to a mobo's graphics connector. If your motherboard does not have built-in graphics, then borrow another graphics card. If you can't borrow another graphics card, remember that it still could be a bad graphics card.
6. If it's none of the above, then it's probably the motherboard that's bad. Very rarely will the CPU be bad (unless it overheated due to the heat sink being clogged with dust or the CPU fan stopped spinning).
Good luck,
Skyzoomer