1


Suppose i have a .bat file saved in a folder .
When my .bat file runs i need to get the path in which this .bat file is saved . I tried Google it but could not find the answer.
Thanks.

  • Duplicate of [What does %~dp0 mean, and how does it work?](http://stackoverflow.com/questions/5034076/what-does-dp0-mean-and-how-does-it-work) which is second on [batch-file votes](http://stackoverflow.com/questions/tagged/batch-file?sort=votes&pageSize=30) list. Not so famous is [In Batch file ~dp0 changes on changing directory](http://stackoverflow.com/questions/12141482/) – Mofi Dec 23 '14 at 13:59

1 Answers1

0

%~dp0 will give you teh path to the bat file.

If you also need the whole path including the name of the bat file itself use %~0.

MichaelS
  • 5,569
  • 5
  • 28
  • 42