When the American Civil War erupted in April 1861, Cornwell raised a company of infantry troops in response to President
Abraham Lincoln's call for volunteers. Cornwell soon disbanded the company, as Lincoln's quota for Pennsylvania volunteers had been filled. In August 1862, he raised another company, which joined the 67th Pennsylvania Volunteer Regiment, attached to the
Army of the Potomac. He became captain and commanding officer of Company I. His company guarded infrastructure in
Annapolis and
Baltimore in 1862 and later deployed to
West Virginia. At the
Second Battle of Winchester in June 1863, Cornwell was captured by the Confederates while sick with typhoid fever in a military hospital. He was held as a prisoner of war at the Confederate
Libby Prison in
Richmond, Virginia, until paroled on May 2, 1864. In July 1864, he joined the staff of General
James B. Ricketts, serving as provost marshal of the 3rd Division of the
VI Corps. Cornwell served at the
Battle of Monocacy and in
Philip Sheridan's
Shenandoah Valley Campaign. He was honorably discharged on October 25, 1864, when his term of enlistment ended. == Later life and career ==