I have a batch file which gets its own short pathname (to eliminate spaces, which gcc doesn't like) for use in subsequent commands:
set base=%~d0%~sp0
This works fine for most cases; for example, if the batch file is located in C:\Program Files, the value of