In June 1919 while traveling across Carpathians, Wilhelm was arrested by Romanian soldiers and detained for three months until on petition of the Ukrainian People's Republic he was released. He then left for Kamianets-Podilsky that served as a capital of Ukraine. After pledging loyalty to the Ukrainian People's Republic, he was made a colonel and headed a section of international relations of the General Staff Main Department within the Ukrainian Army. In protest at Petlura's peace treaty with Poland in 1920, which he considered to be a betrayal, he resigned and lived in exile in Vienna.