In August 1799, hearing that the guards were going on active service, he exchanged into his old regiment as captain and lieutenant-colonel, and served with it in the Anglo-Russian invasion of Holland. In the same year he married Miss Lucy Charlotte Hamilton, the daughter of Colonel Hamilton, of the Coldstream Guards, eldest son of Lord Anne Hamilton and a nephew of the Duke of Hamilton. The next year, though only a lieutenant-colonel, he was selected by Sir Ralph Abercromby to be quartermaster-general of his army in the Mediterranean, at the same time that another young Scotsman, John Hope, who was also to gain fame in Moore's retreat, was nominated adjutant-general. Sir Ralph placed the greatest confidence in Anstruther, and it was mainly on his report, after a visit to the Turkish headquarters, that the Turks would not be ready for a long time, if they could be of any use at all, that Sir Ralph left Marmorice Bay and determined to act alone. Through the whole Egyptian campaign he served with the greatest credit, and was made one of the first knights of the Crescent when the Sultan established that order. On his return he was promoted colonel, was made first deputy quartermaster-general in England, and then adjutant-general in Ireland, and spent some years of domestic happiness at home. But he failed in his attempt to obtain active employment, until, on the return of the Tories to power in 1807, he was appointed brigadier-general, and ordered to take command of a brigade, consisting of the 20th and 52nd Regiments, and four companies of the 95th or Rifle Regiment, which was about to sail to the assistance of Sir Arthur Wellesley in Portugal.