William served in the army from 1814 onward. Like his father he fought against Napoleon I of France during the part of the Napoleonic Wars known in Germany as the "Befreiungskriege" ("Wars of Liberation", otherwise known as the War of the Sixth Coalition), and was reportedly a very brave soldier. He was made a captain ("Hauptmann") and won the Iron Cross for his actions at Bar-sur-Aube. The war and the fight against France left a lifelong impression on him, and he had a long-standing antipathy towards the French.