I'll +1 with previous posts.
Once you have definitely ruled out a flaky power supply, video card, and the onboard battery,..
Do a hard reset to clear the POST/BIOS settings.
If that doesn't fix it, the first suspect is RAM. Download a copy of
Memtest86+ and burn it to a disk. Boot off that and let it run (at least) overnight. If there's any bad RAM in there, Memtest86++ will spot it.
If your PC locks up while running Memtest86+ it's extremely likely that it's
not the RAM that's your problem. (Which is bad news since RAM is easy to replace and not too expensive.)
The second major suspect is likely a crack in the mobo - or a bad capacitor.
Unfortunately, there's no really easy way to diagnose either. You could try gently flexing the mobo while it's running to check for hidden cracks or a bad solder join somewhere on the board. But that's a
very dangerous "test" to perform - and is usually only used as a last ditch verification after you plan on replacing the board anyway. I don't recommend it.
Testing a capacitor in circuit isn't doable without some equipment that would cost more than the average PC. And with surface mount and multilayer circuit boards, you probably couldn't replace a component even if you did identify a bad one.
If turns out it's a bad mobo, maybe it's time for a new board?