SETLOCAL ENABLEDELAYEDEXPANSION causes CD and PUSHD to not persist

前端 未结 4 555
春和景丽
春和景丽 2021-01-18 08:41

I am trying to use setlocal enabledelayedexpansion and cd together in a batch script, which seems to not persist changes back to shell.

The

4条回答
  •  庸人自扰
    2021-01-18 09:03

    Here is proof that it works - start the batch file in any folder above the root.

    @echo off
    setlocal enabledelayedexpansion
    echo "%cd%"
    cd ..
    echo "%cd%"
    pause
    

提交回复
热议问题