The Robins striker rose at the near post to nod home Michael Timlin’s in-swinging corner from the left.
The goal was tough on Rovers who had wasted a golden opportunity five minutes earlier when Craig Disley fired over.
The home side also went close when defender Byron Anthony had a second half shot scrambled clear via a defender and the post, but it was not their night.
Swindon’s Lee Peacock might have done better when directing a 38th-minute header straight at goalkeeper Steve Phillips, while Cox had a 50th-minute shot deflected over the crossbar.
There was little to cheer for a disappointing derby crowd of just over 6,000, but the 567 Swindon fans went home in jubilant mood.