Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 7
    Ok, so why not just use %~dp0 directly? Commented Mar 28, 2016 at 19:04
  • 1
    I imagine this was posted to address the problem mentioned in the accepted answer's comments -- %~dp0 can be relative, which may or may not be a problem depending on use case Commented Feb 6, 2017 at 19:52
  • 26
    %~dp0 can't contain a relative path, d stands for drive and p for path, how a drive could be relative? Commented Mar 31, 2017 at 15:30
  • 14
    In which world? I just tested this answer on Windows Server 2012 r2 and it turns out %~dp0 will be an absolute path even when the script was run as a relative path. Thanks to jeb's comment, I was not fooled by this answer. Why do people just make up stuff and go and start spreading their wild imagination to others. I have this colleague who does this, but I blamed his (young) age. I wish my down-vote would count. Commented May 25, 2018 at 14:25