As Commander, he was at the New York Navy Yard from 1841 to 1843, and then commanded the in the Gulf of Mexico and the West Indies from 1843 to 1845. During the Mexican–American War, Sands commanded the . He was involved in the capture of Alvarado, Tabasco, and Laguna, briefly serving as Governor of Laguna. He also aided in the Siege of Veracruz and the capture of Tampico and Tuxpan in 1847. Sands received various commendations for his role in these engagements.