Our development projects include batch files to build, install and clean the project. Projects are shared with source control and developers and testers have each developed their own directory structures where they store projects on their computer. Accordingly it is important that these batches work whatever their location.
The magic DOS command which achieves just that is cd /d %~dp0
This command actually changes the current directory to the directory where the batch file is located.