The Saxon court gave him a commission, and in 1745 he fought in the Battle of Kesselsdorf as a dragoon. Subsequently, he went to the Netherlands as Count Károly József Batthyány's adjutant. In this position, Mayr distinguished himself on several occasions, such as in the siege of Bergen op Zoom, which was overwhelmed on 16 September 1747. In that year he was also appointed "Rittmeister" (captain of cavalry) in the Saxon army. At this time, several regiments had been disbanded in Saxony, and many officers were placed on half-pay; Mayr recognized the limitations of service in Saxony. He was one of the younger and newer officers and advancement would be hard to acquire. He remained in the service of Field Marshal Count Batthyany until the conclusion of the Peace of Aachen in 1748.