After being freed, he was incorporated to the Argentine Army with the rank of lieutenant colonel, in command of the navy. Until the end of 1811 he was the commander in chief of the comandante of the revolutionary navy, even though command of the squadron was under Juan Bautista Azopardo until his defeat at San Nicolás de los Arroyos. He was made colonel in June 1813 and a member of the Lautaro Lodge, and was named governor of the Córdoba del Tucumán Intendancy, a post he occupied only for a short time. His opposition accused him of governing his province (which at the time included the Cuyo region and the La Rioja Province as if it were enemy occupied territory, obtaining contributions by force, punishing and rewarding the citizens for their adherence - or not - to the Buenos Aires government. In February 1814 he was replaced by Francisco Ortiz de Ocampo, a native of La Rioja who, even though born in the interior, could not control the tendency of the population to favor provincial autonomy, which would soon arrive in any case. Returning to Buenos Aires, Viana became a member of the consulting council for the Supreme DirectorGervasio Posadas, and accompanied general Carlos María de Alvear to finish the siege of Montevideo. He became good friends with Alvear and was. as him, a strong enemy of the Federal Party led by Artigas. Back in Buenos Aires, he was promoted to general and name minister of war and navy, a posthe maintained in the last few months of Posadas's government, and during the last three months of Alvear's government. In March 1815 he organized and commanded an expedition against the federals of Santa Fe Province, but before he could depart in that direction, the commander of his advance forces, colonel Ignacio Álvarez Thomas, revolted at Fontezuelas. That sublevation started the revolution which would force Alvear to resign and go into exile. Viana went with his friend and boss to Río de Janeiro, and upon arriving found he had been deported for life.
Last years
When the Portuguese took Montevideo, in 1818, he went to that city, explicitly accepting a foreign government in his own national soil. He returned to Buenos Aires during the anarchy of 1820 along with Alvear, to work on the revolution which would carry Alvear to a short-lived government in part of the province. Viana, ill at the time remained in the city when Alvear joined the Santa Fe people under Estanislao López, and died in Buenos Aires in 1820.