|A faulty hard drive probably won't cause your system to shut down.|
Software problems can cause your computer to reboot for no apparent reason, but they don't cause the computer to shut down.
Most malware these days is NOT a virus - it's something else.
Malware doesn't normally have any affect whether the computer would shut down or reboot.
You probably either have a faulty power supply, or your cpu is overheating.
Failing power supplies are common.
See Response 2 in this for a lot more info:
I'm assuming you are NOT overclocking the system. That alone can cause overheating of the cpu if you choose inappropriate settings, such as you set the cpu core voltage too high.
Unplug the case/power supply, or switch off the AC power to it otherwise.
Power off your monitor.
Open up the case by removing the left side panel as seen when you're looking at the front of the case.
Check all the connections of the wiring to make sure they are all the way onto their pins and into their sockets, especially the main connector from the power supply. The wires close to the mboard going into the main power connector/socket should be more or less perpendicular to the mboard surface rather than at an angle. Make sure all cards in slots are all the way down in their slots.
If the cpu fan/heatsink has mung (dust, lint, etc.) on it, clean it off, but DO NOT use a vaccuum cleaner to do that (they produce a tremendous amount of static electricity when running, and anything connected to them can discharge that to your components) - use canned air, or an air nozzle if you have access to an air compressor, or an artist's brush that can be used in small spaces, etc. It may be difficult to clean the top of the heatsink under the cpu fan - the most likely place to have mung on it - and the bottom side of the cpu fan blades unless you remove the fan. If you have a case fan, clean that too if it needs it.
Also check for mung on the video card fan and heatsink if it has that, and the power supply's openings / fan.
With the cover still off, restore the AC power, start the computer and make sure the cpu fan spins - if it doesn't spin, if you're sure the power supply is working okay, don't use the computer until you have replaced it.
If it spins too slowly, and/or if it makes rattling or screeching noises, most likely to be noticed when the computer has cooled to room temp, has not been used for a while, and then is started up, the cpu fan's bearings are failing - the cpu is likely to overheat as a result of that if it can no longer spin it's full speed - replace it as soon as you can.
While you're in there...
See response 2 in this - try cleaning the contacts on the ram modules, and making sure the modules are properly seated:
This is relatively rare, but it does happen, and it can cause all sorts of things including for the computer to shut down.
Examine the mboard to see if you have bad capacitors, and/or other findable signs of mboard damage .
This was the original bad capacitor problem - has some example pictures.
History of why the exploding capacitors and which mboard makers were affected:
What to look for, mboard symptoms, example pictures:
Home page that site
- what the problem is caused by
- he says there are STILL bad capacitors on more recent mboards.
Pictures of blown capacitors, other components, power supplies, Athlon cpu's, etc.: