Chesterfield did all the attacking but Barnet held on and stole the points when Drew Talbot tripped Andy Yiadom and Mark Byrne scored from the spot.
Barnet goalkeeper Graham Stack had kept his side in the game in the first half with a string of outstanding saves as Chesterfield looked to launch Cook's managerial
reign in style.
He denied Danny Whitaker and Sam Togwell twice in the space of a minute before pulling off a double save from Jack Lester two minutes before half-time.
Barnet created little and they continued to soak up pressure in the second half with Edgar Davids harshly booked in the 65th minute for a challenge with Togwell before Whitaker volleyed over eight minutes later.
Chris Atkinson shot narrowly wide of Stack's left post in the 78th minute but Barnet stunned the home side in the last minute when Yiadom was clipped by Talbot and Byrne cooly sent Richard O'Donnell the wrong way with the spot kick.