The Cobblers warmed up for a critical week of Cup football by stashing away three welcome Division Three points.
Colin Calderwood's side face Colchester on Tuesday night in the LDV Vans Trophy before their money spinning glamour FA Cup match with Manchester United next Sunday.
There was always a danger that the looming presence of the mighty Reds would leave Northampton off the pace, but a lack-lustre performance by the visitors contrasted sharply with a bright home display.
Richard Walker has spent the last three months on loan at Sixfields but he must return to Blackpool after Tuesday. But that didn't stop him firing his sixth goal in a Northampton shirt, the opener arriving in the 20th minute after Des Lyttle headed a ball back into the box after a Martin Smith corner was cleared.
Smith then rocked the York bar with a left foot volley before former Northampton goalkeeper Mark Ovendale made a full stretch save from Chris Hargreaves.
But the Cobblers turned around with the two goal cushion their play warranted when the unfortunate Jon Parkin turned a Smith corner into his own net in first half injury time.
York had their best chance of the match two minutes after the restart, when Lee Bullock ran on to a Justin Walker pass but the striker's shot lacked venom and Lee Harper was able to save.
The visitors left it late before snatching a consolation, Bullock atoning for his earlier lapse by poking home a loose ball from a corner taken by player-boss Chris Brass in injury time.
Northampton's Director of Football John Deehan said: "There has been so much intrigue and speculation here over the last 48 hours because of the Manchester United game. It has been very difficult to concentrate on this League fixture so the players have done particularly well to focus on the job in hand." City boss Brass said: "Had Lee taken that chance straight after half time I think we would have taken something out of the game."