Matty Blair and Jason Walker struck early in the second half to end York's four-match winless streak with a 2-0 victory at Aldershot.
The Shots should have opened the scoring after 20 minutes when Michael Ingham could only parry Danny Hylton's shot to Craig Reid but the striker could only hit a post from two yards.
Jamie Young made an outstanding save to stop Chris Smith's diving header two minutes later. Ashley Chambers then combined with Walker to set up Blair in the 41st minute, but Young's heroics continued as the first half ended goalless.
However it took the Minstermen less than three minutes to open the scoring after the restart when Aldershot lost possession near the halfway line and an incisive passing move saw Walker release Blair, who kept his cool to beat Young.
Walker scored the second from the penalty spot in the 51st minute after he was tripped by Sonny Bradley, who wasted several opportunities to clear his lines.
Substitute Alex Rodman had Aldershot's best chance to reduce the arrears but he blazed over with only Ingham to beat.