Get directory containing the currently executed batch script
Solution 1:
%~p0
Will return the path only.
%~dp0
Will return the drive+path.
More info on the subject can be found on Microsoft's site.
Information about this syntax can also be found in the help for the for command by executing for /?
on a Windows OS.
Solution 2:
The current directory is held in %CD%
Solution 3:
Some expressions that effect the filename:
~f0
will give the fully qualified file name.
~dpnx0
will give the same as ~f0
, but this shows you that you can break it down into parts: d=drive p=path n=name x=extension