Shortly after the outbreak of the Second World Warin September 1939, Hayes led his battalion overseas to France as part of the British Expeditionary Force, arriving there in the third week of September. The battalion, along with the rest of the BEF, was not immediately engaged in action, unlike in World War I, and instead spent most of its time in France digging defensive positions, with relatively little time being allotted to training, as most of the Allied politicians and military commanders expecting a repeat of the trench warfare of 1914–1918. Hayes did not remain with his battalion long, however, as, in January 1940, he returned to England to become Commandant of the Company Commanders' School, and, in August, was promoted to brigadier and given command of the 35th Infantry Brigade, a second-line Territorial Army unit, which had recently fought in the Battle of France where it had suffered heavy losses. The brigade formed part of the 1st London Division, then commanded by Major General Claude Liardet, which in November was redesignated the 56th Infantry Division, with Hayes's 35th Brigade subsequently being retitled the 169th Infantry Brigade. He remained with the brigade, which was serving in Kent with the rest of the division as part of Lieutenant General Andrew Thorne's XII Corps on anti-invasion duties and training to repel a German invasion of the United Kingdom, until May 1941. On 10 May 1941 his permanent rank was advanced to colonel. On 22 September 1941 he was promoted to the acting rank of major general and succeeded Major General Edward Lawson as General Officer Commanding of the Yorkshire County Division, a recently created formation, comprising the 201st, 218th and 221st Independent Infantry Brigades, but no divisional troops. The division, serving under Lieutenant General Henry Willcox's I Corps, was one of several static divisions created with the sole intention of providing coastal defence, guarding the beaches against invasion. However, just two months later, he was posted to the 3rd Infantry Division as its GOC, thereby succeeding Major General James Gammell. The division, in GHQ Home Forces reserve, was a Regular Army formation that had served in France under then-Major General Bernard Montgomery, and was composed of three infantry brigades – the 8th, 9th and 37th Infantry Brigades, and supporting divisional troops. In June 1942, the division went through another reorganisation, which resulted in the loss of the 7th Brigade, replaced by the 33rd Tank Brigade, as part of the "mixed division" experiment, which was intended to strengthen infantry and tank cooperation, although in the end the experiment was eventually abandoned. He was not to remain with the division for much longer, however, as in mid-December 1942 he was relieved as GOC of the 3rd Division, his successor being Major General William Ramsden. He continued his war service and commanded the Nigeria Area in West Africa from January 1943 and returned to England to command the East Central District from late 1943 before becoming Head of the British Military Mission to China in early January 1945, and was made GOC British Troops in China in the following year. In that capacity he witnessed the surrender of Japan in China in September 1945. For his services he was awarded the Companion of the Order of the Bath in 1946.
Postwar
Hayes retired from the army, after thirty-two years of service, on 20 January 1947. He maintained his connections with the army and his regiment, becoming Colonel of the Royal Norfolk Regiment from 9 February 1951 until his sudden death, caused by a short illness, in August 1951.