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*

6
  • 13
    This does not answer the question. %CD% gives the current directory, while what was asked was the directory of the script. Commented Oct 7, 2008 at 11:58
  • 3
    @ketorin: This DOES answer the question. %CD% will change if the script itself change directory throughout it's usage (pushd/cd/..) but %~dp0 will NOT change and always point to where the script is located. Commented Sep 8, 2009 at 17:18
  • -1 I can't tell if this answers the question or not. Can you show me an example? Commented Jul 25, 2013 at 16:01
  • 1
    @IainElder - you're probably right, I re-visited this answer a few days ago and wasn't too happy with it. The comments on Raymond Chen's blog, which I refer to, seem to have been blitzed by MS - so therein lie the dangers of answers that rely entirely on linked external sources. I did try to find some other material to back up my answer but it's so long ago in the mists of time now. Flagging for deletion. Thanks for tipping me over the edge with this one :) You don't happen to work for SkyScanner do you? Commented Jul 25, 2013 at 23:49
  • 1
    @Kev It's okay to refer to external sources if you copy the helpful part to Stack Overflow. I guess now it's too late! And yes, I have been known to lurk in the Skyscanner data center ;-) Commented Jul 26, 2013 at 13:51