When the French invaded the Netherlands in 1793 during the Napoleonic wars, William V, king of Holland asked Britain to protect the Dutch colonies including the cape.
The British occupation of South Africa was by force in order to break the Dutch resistance.
On 11th/June/1795, the British expedition under Sir George Heith Elphistone captured and occupied the cape.
The British troops were under the command of Major General Sir James Henry Craig.
Sir George presented a document to the cape governor which had a former order of acceptance of the British occupation.
On 17th/Aug/1795 the British continued to attack the Boer troops at Muizenberg as they retreated to Weisberg.
The British General Clarke attacked Weisberg with 3000 troops and disorganized the Dutch forces.
By 14th/Sept, the British had occupied nearly the whole of the cape.
The cape governor sent two representatives to sign the treaty to end the war. This treaty was signed on 16th/Sept/1795.
By the treaty the British flag replaced the Dutch Flag at the cape.
But this first occupation was short lived and no serious reforms were introduced by the British.
In 1802, France and Britain restored peace among themselves by signing the treaty of Amiens of 17th/03/1802.
By the terms of the treaty, Britain was to withdraw from the cape and the French to leave Holland.
From 1803 – 1805, the cape was thus under the Batavian republic a new name Holland had assumed after the change
In 1806, France violated the treaty of Amiens by re- occupying Netherlands. This put the British interest at cape
In 1806 the British administration sent 61 worships under the command of General David Bairds and re-occupied the cape.
Although the troops occupied the cape in 1806, Britain did into acquire it formally not until 1814.
Therefore the Vienna settlement of 1815 clearly documented and gave Britain a go ahead to officially occupy the cape.