During the Invasion of Poland, Szczepanik was interned in Lithuania and later captured by the Soviet forces. From 1940 until 1942, he was held prisoner in the Soviet Gulag camps in Kozielsk and Kola Peninsula. Following the outbreak of the Russo-German War and signing of the Sikorski-Mayski Agreement, he was released and joined the Polish II Corps under general Władysław Anders. As an Officer (and eventually Major) in the Polish Army, he served with distinction in the Fifth Polish Artillery Regiment – notably in the battles of Monte Cassino, Ancona, and Bologna. He was one of the first members of the Allied troops to enter Bologna. In 1945 he received the Cross of the Valorous, and the following year was awarded the Silver Cross of Merit with Swords. In addition, Szczepanik was awarded the Italian Cross of Military Merit by the King of Italy and several other Polish and British campaign medals. He also served as a liaison officer with the Royal Artillery Training Team, commanded by Colonel R.R. Hoare.