The Robins were ahead in the 24th minute when Williams, who spent two years at Yeovil until this summer, ran from the halfway line before shooting home from the edge of the area.
James Collins got Swindon's second in the 28th minute when he guided home Joe Devera's deep cross from the left.
But James Hayter gave Yeovil hope shortly before half-time when his header from substitute Keanu Marsh-Brown's cross hit the bar and went over the line, with goalkeeper Wes Foderingham unable to keep it out.
Yet just two minutes later Darren Ward restored Swindon's two-goal advantage heading into the break with a shot from close range after Marek Stech had failed to hold Devera's header.
Swindon manager Paolo Di Canio sent on new loan signings Chris Martin and Danny Hollands in the second half but his team had to wait until injury time before getting their fourth goal. Collins cut in from the left and unleashed a fierce shot beyond Stech to complete the scoring.