How does Windows detect battery issues?

Laptop batteries have a small chip inside that controls/monitors the charging process and also monitors the number of charge/recharge cycles.

This chip is factory programmed with information how this sort of battery typically degrades over time.
It also can derive information from the charging cycle itself: The time it takes to reach full-charge at a given voltage/current changes when the battery gets worn out.
(Voltage drop during discharge is not reliable as it depends a lot on the amount of current drawn while discharging, so it varies with the use-pattern of the laptop.)

Windows communicates with this chip to get information about the battery health.


It depends on the laptop but laptop batteries are rather smart. They can calculate how long they can last and how much their capacity is lost because of usage and aging. If your 5 year old laptop just reported that you should consider replacing it, then you are lucky, as a battery's life is 3 years average.

By the way if your computer is 5 years old, I would rather recommend replacing the laptop, instead of just battery. Because 5 years is a long time for computers, and if one other part of your computer does not fail, your HD would likely to fail at the near future.