I have a batch file for doing some automated deployment magic. It calls other batch files via relative paths. The problem with this is that it doesn't work if you call the batch file from a different directory.
Once I started looking I came across this litte gem
You can then get your batch file to run from its own directory as follows...
Once I started looking I came across this litte gem
%~dp0
. %0
is the name of the batch file.~dp
gives you the drive and path of the specified argument. You can then get your batch file to run from its own directory as follows...
pushd %~dp0
... do batch file stuff
popd