setlocal PATH=c:\path\to\locallib\bin;%PATH% &rem PATH=%~do0locallib\bin;%PATH% &rem ... the second works in a .bat/.cmd set PERL5LIB=C:\path\to\locallib\lib\perl5 &rem set PERL5LIB=%~dp0locallib\lib\perl5 &rem ... the second works in a .bat/.cmd pp -x -o out.exe in.pl &rem see longer version, below