I have been having this problem for a while and not quite sure how to diagnose the problem. If the computer is just sitting without being hit or moved, it works perfectly fine (can stay on for weeks as a time without turning off). However if you bump it with your foot and plug something into the back and move it a bit it usually just shuts off. Once it is off it will not turn back on until I wiggle the power supply cord, which makes me think it is the power supply. But I don't understand why it would do that when the cord is in there good. Any suggestions would be greatly appreciated.
Power cords rarely go bad unless they are stressed (under furniture, crimped, etc) so that's not likely (as you have found out).
Could be a loose connection between the PSU power cord fitting and the PSU transformer - which would mean a new PSU.
More likley I would suspect another loose connection on either an expansion card (video, modem, network, TV Tuner, etc.) or a loose power connection.
I could also be a grounding issue (weak ground on screws for mobo, power supply screws, or something more obscure).
I once had a network card that would cause intermittent power issues. Once I removed it I was golden.
Check all your connections - remove and re-seat them all - data and power. Reseat all your cards (Video, modem, network card, etc.), memory, power, everything. If it's not a permanent part, remove and reseat systematically until you find the culprit.
You could also remove power and data connecitons for all non-essential hardware then reconnect one at a time and test to see if one of those items has an internal problem (non-essential would include, card readers, floppy drives, dvd/cd rom/burners, etc).