@echo off echo starting setlocal cd c:\tmp set A=B perl -e "$ENV{X}='Y'; system('cmd')" echo finished