I'm with Kirby on this.
Assuming you're running XP:
If you get a message "Windows is shutting down" you have a software / virus problem. If it restarts (does not shut off, but reboots) the system may be restaring because of a system failure. If it just powers off, you probably have powersupply problem.
In either of the first two cases, check the event viewer. it should give you information regarding the nature of the problem. If there are errors, post the event ID's and we might be able to help. You can also change the recovery options (system properties, Advanced, startup and recovery), unmark the box in the system failure section that says Automatically restart. Instead of restarting you will see the infamous Blue screen of Death (BSOD). Take carefull note of the first three lines or so (Stop error 0x000001e ... IRQ_NOt_LESS_OR_EQUAL in module ntvdm.dll ... ). That info will tell you what's going on.