The result helped Rangers boss Ally McCoist to achieve a personal milestone, as he guided a team to the quarter finals of a major domestic cup competition for the first time.
Rangers took the lead after just eight minutes when Pars defender Ryan Williamson was caught in possession after he cut out a David Templeton pass inside the box, and Shiels turned to scoop the ball past Ryan Scully.
Shiels struck again on 24 minutes as he pounced on the rebound to shoot high into the net following a Scully save from Jon Daly's free close-range header.
The Northern Ireland striker was denied a possible third as he slipped on the poor playing surface, which had been cutting up from the start of the match, just as Shiels was about to shoot from just inside the box.
Goal number three was merely delayed though and Templeton (37) bust into the penalty area on the Rangers left and sent his low drive under the arm of the diving Scully.
Shiels completed his treble two minutes after the interval as he despatched a loose ball into the unguarded goal after Scully had advanced to thwart Lee Wallace.
Dunfermline's only chance of note came late in the first half when Ryan Wallace thundered a shot towards the near post, but keeper Cammy Bell got down to block.
The margin of victory could have been even bigger though as Scully twice made good saves to deny Templeton, while Bilel Mohsni sent two point-black headers wide of the target and Ian Black struck the bar with a dipping drive from 25 yards.
But Rangers will be hoping for a favourable draw in the next round to enhance their chances of reaching the semi-finals, which will be played on their home ground.