Chosen Solution
The laptop runs fine when I have it plugged into the wall, but as soon as I unplug it it shuts down.
Replace the battery and it should work
It’s possible that the battery is not charged enough to remain on without being plugged in, so check that first. If it seems to be fully charged or is not charging at all, then replacing the battery might be necessary.