Chosen Solution

Replaced the battery and now the PC randomly shuts down even when connected to charger. Is this a defective battery? I have removed and re-installed the battery to ensured a solid connection. On boot up the display is saying that a non-HP battery has been put in this machine. (this is true, I am using an aftermarket battery) After that the laptop launches windows.

jayeff. I took the new replacement battery out of the PC and just used the AC charger supply.  This solved the random shut downs.  I then re-installed the old HP battery and the boot up display saying that a non-HP battery error is gone. Also, no random shutdowns. It looks like the new replacement battery is causing the problem.