see this example please:
C:\
..ex1\
....start.bat
....111\
......1.bat
......222\
start.bat:
@echo off
pushd 111
call 1.bat
popd
echo CD is wrong:%cd%
pause
1.bat
@echo off
setlocal
pushd 222
echo 1.bat says we are in %cd%
when i run start.bat i get:
1.bat says we are in C:\ex1\111\222
CD is wrong:C:\ex1\111
as you see CD (current dir) should be C:\ex1 not C:\ex1\111 because i used setlocal, it seems that setlocal have no effect when pushd is nested in that way
if i change
pushd 111
call 1.bat
to
cd 111
call 1.bat
or to
call 111\1.bat
everything works fine so setlocal works fine in simple pushd cases
is this a bug? if not can you explain why this happens?