He was in temporary command of the regiment during Massena's retreat from Torres Vedras, at the Battle of Fuentes de Oñoro, and at the final siege and fall of Badajoz. He became regimental major after the Battle of Bussaco, and received a brevet lieutenant-colonelcy after the Battle of Salamanca; he conducted the light troops of Picton's division at Orthez, and succeeded to the command of his regiment on the fall of Colonel Forbes at the Battle of Toulouse. In the course of these campaigns he was repeatedly wounded: he was shot through the body, through the neck, and through the right arm, a bullet lodged in his left arm, and another in his right leg. In 1819 Greenwell took his regiment to Ceylon, and commanded it there for six years, but was compelled to return home through ill-health before it embarked for Burma. In 1831 he was appointed commandant at Chatham, a post he vacated on promotion to Major-general on 10 January 1837.