If the screen lights up and the operating system loads, and it gets to a desktop, then the computer is booting up. What it's not doing is staying powered up once you've booted up. The first thing I would try is resetting the power manager/SMC controller, just in case this is just a system glitch:
How to reset the System Management Controller (SMC) on your Mac
I doubt that's the problem, but the fact that disconnecting/reconnecting the battery seems to change things may be power management-related.
But really, it sounds like the computer is overheating, possibly due to one or more of the following issues:
- Clogged or failing fans
- Disintegrating heatsink compound between the CPU/GPU and the attached heatsink
- Clogged air vents
I'm guessing that when you try to start up the computer, the fans are making a lot of noise. Depending on your environment, fans and air vents can get clogged with dust or pet hair; cat hair is particularly bad, as it's usually finer than dog hair, and can get deeper into the machine. I would open up the machine and clean out whatever gunk has accumulated in the fans and air vents, then reassemble and see if the problem is solved.
MacBook Pro 17" Models A1151 A1212 A1229 and A1261 Right Fan Replacement
MacBook Pro 17" Models A1151 A1212 A1229 and A1261 Left Fan Replacement
Links to the replacement fans for the various generations of MBP 17" are available from the guide pages.
The left fan is more difficult to remove than the right, as there are more things to move out of the way. You can brush the blades of the fan with a dry toothbrush to clean the dust out; a can of compressed air is also useful.
Cleaning the air vents (on the back of the bottom case, underneath the display hinge) is often difficult unless you remove the logic board to provide clear access from both sides of the vent. You can try to scrub the vent from the outside with your toothbrush; you can also try to scrub from the inside once you've removed the fans, as the fan vents are one of the primary collection points for debris.
Pay attention to the sound of the fans after you reassemble the computer and power up. If the shutdown problem still occurs, and you hear unusual noise from the fans such as rattling or whining, one or more fans may need replacement. Do them both; they're at least ten years old, and all moving parts eventually wear out.
In the event that fiddling with fans doesn't fix the problem, it's possible that the heat sink compound attaching the metal heat sink to your CPU and graphics chip has dried out and is crumbling away. This means that heat generated by these chips isn't getting out through the metal (which works like a car's radiator ro keep the chips from overheating). When enough heat builds up in the chips, they freak out and start misbehaving; if it gets bad enough, the computer shuts down to prevent burning the chips out.
Removing the logic board and reapplying thermal paste is a much more involved task than replacing fans; you have to remove the logic board and flip it over, because the heat sink is on the lower side of the board. Once the board is out, take advantage of the opportunity to clean the case's air vent thoroughly.
MacBook Pro 17" Models A1151 A1212 A1229 and A1261 Heat Sink Replacement
MacBook Pro 17" (Model A1151) Heat Sink
MacBook Pro 17" (Models A1212/A1229) Heat Sink
You haven't identified the specific generation of MBP 17" you have. The model ID is printed on the bottom of the computer, just near the hinge; it will be one of these four generations:
- A1151 (2006)
- A1212 (2006-2007)
- A1229 (2007-2008)
- A1261 (2008-2009)
The big distinction between these generations (aside from the normal CPU/GPU/drive/connector variations) is that the A1261 generation has a heat sensor, which might contribute to shutdown issues if it's malfunctioning and transmitting incorrect information to the system. The instructions for replacing the thermal sensor are included in the replacement guide for the A1261 heatsink.
MacBook Pro 17" (Model A1261) Middle Thermal Sensor