Hi,
Do test the AC adapter and battery first.
- Remove the battery then plug in the AC adapter, boot it up and see if it will still shutdown without the battery.
- If it will not shutdown without the battery that means your battery is faulty.
- If it will still shutdown that means it can be something else inside the laptop or the AC adapter is faulty.
- Try and test your AC adapter to see if it's supplying enough voltage to power the laptop or try another AC adapter that has the same voltage and if it will still shutdown, turn to the laptop itself.
- Chances are the laptop is overheating and is causing the automatic shutdown or there could be other motherboard part that is failing.
- Do try to clean the inside of your laptop as well, make sure there's no dust stopping the fans from spinning and apply new thermal paste onto both GPU and CPU.