What does %~dp0 mean, and how does it work?

后端 未结 7 2106

I find %~dp0 very useful, and I use it a lot to make my batch files more portable.

But the label itself seems very cryptic to me... What is the ~<

7条回答
  •  故里飘歌
    2020-11-22 02:54

    The variable %0 in a batch script is set to the name of the executing batch file.

    The ~dp special syntax between the % and the 0 basically says to expand the variable %0 to show the drive letter and path, which gives you the current directory containing the batch file!

    Help = Link

提交回复
热议问题