Coke passed 1845–48 on furlough in Europe, thereby missing the First Anglo-Sikh War (1845–46), but returned to India in April 1848 following the outbreak of the Second Anglo-Sikh War, and Captain Coke joined the army of Sir Hugh Gough, Commander-in-Chief, India, at Ramnagar as a volunteer in 1849, doing duty with Colonel Tait's 2nd Irregular Cavalry.
On 23 February 1850, the regiment was reviewed by the Commander-in-Chief, Sir Charles Napier, who reported to Colonel Henry Montgomery Lawrence, Deputy Commissioner of Peshawar:
"As to Coke's regiment, I have seen nothing superior to it in drill – it is admirable; both you and I saw how this brave corps fought under its excellent leader in our five days' campaign in the Kohat Pass.
Coke also received thanks of the Honourable Court of Directors and the Governor of India for dispatch in raising the regiment and its services in the Kohat Pass.
He received the thanks of the Governor-General in Council and the Punjab Board of Administration for the conduct of the regiment in the campaign under Sir Colin Campbell, in the Ranagie Valley, in May 1852.
In 1850, Coke was appointed Deputy Commissioner of Kohat, with civil and military charge of the district on the frontier of Afghanistan, then in a very critical state, the Hill Tribes making constant raids on the villages.
When Lord Napier of Magdala, as Commander-in-Chief in India, lately visited the district in his tour of inspection, he assured Major-General Coke that he was by no means forgotten by the inhabitants, whom he had endeavoured to rule to their own benefit and the advantage of the State.
Twice was he wounded; but his unflinching demeanour, his power of leadership, whilst it gained the supreme confidence of his men, extorted respect and admiration from his enemies.
In September 1855, he received the thanks of the Governor-General, Lord Dalhousie, for the conduct of his regiment at the capture of the intrenchments on the Summana Mountains, 5,000 feet high.
" Summoned to Delhi early in August, Coke brought to the part assigned him in the siege all the qualities which had made his name on the frontier.
At the same time he ordered Lieutenant Lumsden, commanding his own regiment, to skirmish through the gardens on the left – the direction in which he expected to find the enemy in force.
He had read how, in the olden days of Indian warfare, the Brinjaris – dealers who carry their grain on pack cattle – had made themselves eminently serviceable.
Lord Lawrence, writing to The Times in November 1878, on the Afghan war, named Major-General John Coke as one of the "models of frontier officers, good administrators, and able soldiers – men who devoted their health, and even their lives, to their duty."