Windows batch file starting directory when 'run as admin'

前端 未结 8 1697
情书的邮戳
情书的邮戳 2020-12-12 20:02

I have a batch file which is in a directory and must be run from there as well because it updates files within this directory.
This works perfectly fine, except when t

8条回答
  •  醉酒成梦
    2020-12-12 20:45

    Better than cd is pushd which will

    • change drive letter if starting from D:\...
    • assign a drive letter if on a UNC network path

    So pushd %~dp0 is good.

    Good practice is then to call popd when done.

提交回复
热议问题