Louis Bonaparte named Janssens Secretary-General of the Department of War upon his return. He held a series of high-ranking administrative posts within the kingdom until the abdication of Louis Napoleon and the annexation of the Netherlands by France in 1810. On 11 November 1810, he was appointed governor-general of the territory known, before the annexation, as the Dutch East Indies, replacing Herman Willem Daendels. He arrived in Batavia, Java on 15 May 1811 and immediately involved himself in efforts to strengthen the colony's defenses. Java benefited from a larger amount of both Dutch and French troops, as well as better defenses, compared to the Cape Colony. However, the British invasion fleet arrived shortly thereafter, on 30 July, led by Sir Samuel Auchmuty.