Recently I faced this problem in my laptop. When I was trying to upgrade my windows pc from windows vista to windows 7 during windows upgrade my laptop was automatically shutdown. Again I tried but same result. I am using dell inspiron 1525.I was suspected that it might be because of virus.
I am using Microsoft Security essential and one more antivirus software then how come it happened? After that I found that auto shutdown problem is not because of virus it is due to laptop overheating.
Again I tried and I checked my laptop yes my laptop was overheated.
Windows upgrading will take several minutes to complete so this kind of long time use charge you laptop first then unplug your laptop charger (if fully charged) or you also want to charge your laptop then put something under the laptop so that it raises above ground level thus improving circulation of air in the laptop. This might be the temporary solution.
For permanent solution you need to remove dust from the inside it. If you are using dell inspiron 1525 try this. ¬†