How to get the path of the batch script in Windows?

前端 未结 8 1331

I know that %0 contains the full path of the batch script, e.g. c:\\path\\to\\my\\file\\abc.bat

I would path to be equal to

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 05:23

    %~dp0 may be a relative path. To convert it to a full path, try something like this:

    pushd %~dp0
    set script_dir=%CD%
    popd
    

提交回复
热议问题