This is a dead easy variable: %~dp0. We'll get back to what this sequence actually means in a later post but you will notice how much it looks like the argument 0 (%0 or %~0 in this case) I mentioned in an earlier post. It's just had a couple of characters added in (dp).
So, now for a simple echo example:
@echo off
:action
echo Current batch run path: %~dp0
goto eof
:eof
echo Press a key to quit...
pause > NUL
goto blackhole
:blackhole
This looks too simple to actually be of any use but actually using the current run path can be very handy if you store configuration or content files in the same directory as your batch file (or a subdirectory thereof)!
More about that soon.
Thoughts?
No comments:
Post a Comment