Gerok entered the "Queen Olga" Grenadier Regiment No. 119 on 4 April 1872 as a Fahnenjunker; on 11 November 1872 he was named Fähnrich and on 17 October 1873 promoted to second lieutenant. On 23 May 1881 he was transferred to the "King Karl" Grenadier Regiment No. 123, with a simultaneous promotion to first lieutenant. Until 29 September 1885 he served as regimental adjutant; he then became adjutant of the 54th Infantry Brigade in Ulm, part of the 27th Division, and on 18 August 1888 became a captain. He was then transferred as a company leader to the "King Wilhelm I" Infantry Regiment No. 124. From 28 December 1893 to 23 February 1897, he functioned as adjutant to the XIII Army Corps, becoming a major on 18 June 1895 and then Commander of the 3rd battalion of the "Kaiser Friedrich, King of Prussia" Infantry Regiment No. 125. On his promotion to lieutenant colonel, he was transferred on 7 July 1907 to the staff of the "Freiherr von Sparr" Infantry No. 16. On 1 April 1903, he became a member of the Reichsmilitärgericht, the highest court of the Army under German military law. On 19 July 1904 he resigned from the court and with a simultaneous promotion to colonel, took command of the "Grand Duke Friedrich of Baden" Infantry Regiment No. 126. On 18 August 1908 he was promoted to major general and to command of the 54th Infantry Brigade in Ulm. Following his promotion to lieutenant general on 21 April 1911, he served as commander of the 26th division. One and a half years later, on 21 September 1912, he was appointed Governor of Ulm. Following the outbreak of World War I, Gerok was appointed commander of the 54th Reserve Division on 25 August 1914, and on 30 August promoted to the rank of infantry general. He was succeeded as divisional commander by Infantry General Paul von Schaefer and on 11 September 1914 appointed general in command of the XXIV Reserve Corps. He led them in battle first on the Western Front in the Battle of Lille and the First Battle of Ypres. The corps were then withdrawn and sent to the Eastern Front, where they first saw action at the Battle of Łódź. From 13 May until 9 August 1916, they took part in the Battle of Verdun and then moved into the Carpathians, where Gerok also served simultaneously until 24 November 1917 as commander of the Army Group named for him. He led the corps in the battles for terrain in Champagne and at Rheims, until 18 February 1918. He was then relieved and once more appointed Governor of Ulm. He carried out this function until 22 May 1918, when he was unassigned until his final dismissal from duty on 10 June 1918. With effect from that date, he was assigned à la suite to the "King Karl" Grenadier Regiment No. 123 by King William II of Württemberg.