%~dp0 to get the path a batch file is located in. This is useful if you want to access resources that are stored relative to the batch file. This allows you to get around the fact that the current directory for a batch file is the directory you ran it from, not where the batch file is located.
An example would be,
This would call another script in the same directory as the batch file called program_locations.bat. There is no slash between the two bits because the path returned by
%~dp0 has a trailing slash already.
There are a whole bunch of other things you can do with
%~ but that’s the one I tend to use the most often. The d stands for drive and the p for path. The overall command is working on %0, the program being run.