It was decided Prince William, as a future king, would not serve on the front line, Gen Sir Mike Jackson said as he revealed Queen Elizabeth’s comments in an ITV series.
The Real Crown: Inside the House of Windsor is a five-part series that can been viewed in full from April 20.
Gen Jackson, who served as Chief of the General Staff from 2003 to 2006, says in the final episode: “The chiefs have an audience with the queen once or twice a year.
"You need to have done your homework. She’s very wise.
"I used to tell my staff, see if you can get the midday slot because after half an hour or 40 minutes the queen would ring a small bell and, 'Time for a sherry, I think, CGS.' 'Very good idea, ma’am.'
“What goes on in those audiences and who says what to whom remains for the two people involved.
“And I will break the rule … about not divulging what goes on on this one occasion when she was very clear, she said: ‘My grandsons have taken my shilling, therefore they must do their duty.'
“And that was that. But it was decided that for Prince William as heir to the heir, the risk is too great. But for his younger brother, the risk was acceptable.”
Queen Elizabeth II's funeral: extraordinary images from an extraordinary day - in pictures
King Charles III follows behind the coffin of Queen Elizabeth II, draped in the Royal Standard with the Imperial State Crown and the Sovereign's orb and sceptre on top, as it is carried out of Westminster Abbey after her state funeral. Reuters
The ceremonial procession of the coffin of Queen Elizabeth travels down the Long Walk as it arrives at Windsor Castle for the Committal Service at St George's Chapel. AP
Pall bearers carry the coffin into St. George's Chapel, in Windsor. AP
A Royal Guard stands by floral tributes at Windsor Castle. AFP
The coffin of Queen Elizabeth is pulled on a gun carriage by Royal Navy sailors to Westminster Abbey. Getty Images
Prince William and Prince Harry follow the coffin of the queen after her state funeral in Westminster Abbey. AP
Emma, the monarch's fell pony, stands as Queen Elizabeth's coffin passes at Windsor Castle. PA
Members of the royal household stand with Queen Elizabeth's Corgis, Muick and Sandy, as they await the funeral cortege at St. George's Chapel, Windsor. AP
Catherine, Princess of Wales, attends the state funeral service in London. AFP
The coffin of Queen Elizabeth is pulled along The Mall following her funeral service in Westminster Abbey. AP
Flowers thrown by the public lie on the hearse carrying the coffin as it arrives at Windsor Castle. AP
King Charles at the state funeral in London. Reuters
People sleep before the funeral service at Westminster Abbey. AFP
A giant screen honouring the late queen at Piccadilly Circus in London. EPA
King Charles looks towards the coffin of his mother at Westminster Abbey. Getty Images
Meghan, Duchess of Sussex, sitting in a car as a British flag is reflected in its window. AFP
Buckingham Palace household staff return through the gates of the palace after paying their respects. AFP
Staff Sergeant Yeoman Darren Fowler, right, and Captain Rebecca Cooper from the Royal Signals at the Elizabeth Tower, checking that Big Ben Chimes in time with gunfire during the state funeral procession. EPA
King Charles salutes as he is driven past Wellington Arch in London. Getty Images
The London skyline is seen as the procession moves down The Mall. Getty Images
The coffin of the queen is pulled on a gun carriage by Royal Navy sailors from Westminster Abbey. Getty Images
Princess Charlotte arrives by car ahead of the funeral in central London. AP
The coffin is carried into St George's Chapel for the Committal Service, in Windsor Castle. AP
A woman cries in London's Hyde Park while watching the funeral service. AP
Prince George looks towards his father Prince William during the Committal Service at St George's Chapel. Getty Images
Queen Elizabeth's coffin is driven along the Long Walk towards Windsor Castle. Reuters
People waiting along the route that the coffin will be pulled on a gun carriage in central London. AP
King Charles and the Queen Consort Camilla follow the coffin at St George's Chapel. AP
The Royal State Hearse arrives at Windsor Castle. Getty Images
King Charles follows the State Gun Carriage as it carries the coffin at Westminster Abbey. PA
Members of the public gather to see the coffin as it travels from Westminster Abbey to Wellington Arch in London. Getty Images
King Charles and members of the royal family follow behind the coffin as it is carried into Westminster Abbey. PA
The Imperial State Crown resting on the coffin. Getty Images
The hearse transporting the coffin is covered in flowers thrown by the public. AFP
The Bearer Party of The Queen's Company, 1st Battalion Grenadier Guards carries the coffin from Westminster Abbey. AFP
Prince Harry was an army officer and Prince William an officer cadet when Gen Jackson was head of the army.
The younger brother served two tours in Afghanistan, where UK forces were part of a multi-national operation fighting the Taliban insurgency.
In Prince Harry’s first tour of Afghanistan, during 2007-2008, he was a forward controller co-ordinating air strikes on Taliban positions.
His tour of duty was abruptly ended when foreign websites broke a media blackout on reporting details of his service.
With a burning desire to return to the front line, Prince Harry retrained as a helicopter pilot and was sent back to the front, serving as an Apache co-pilot and gunner during 2012-2013.
Prince William was an RAF search-and-rescue helicopter pilot but was not sent into an active combat zone, unlike his uncle, the Duke of York.
At 22, Prince Andrew served in the Royal Navy as a Sea King helicopter pilot in the Falklands War in 1982.
His service included flying his aircraft as a decoy target, trying to divert deadly Exocet missiles away from British ships.