To determine the relative path of the current directory to the script, and then change to that directory. Try including this simple code in a .bat file and run it:
set REL_DIR=%~d0%~p0
pushd %REL_DIR%
echo %REL_DIR%
pause >nul
The %~d0 will select the drive (volume) on which the script resides, while the %~p0 will select the relative path of the script.
To use a modifier, type the percent (%) character followed by a tilde (~) character, and then type the appropriate modifier (that is, %~modifier).
The following table lists possible combinations of modifiers and qualifiers that you can use to get compound results.
SOURCE | LINK | LANGUAGE | ENGLISH |
How to use special batch DOS parameters (DOS programming) – http://heelpbook.altervista.org/?p=35946 – HeelpBook – 20/02/2013 – 17:00 – Visit http://www.heelpbook.net OR http://mobile.heelpbook.net on your tablet! #HeelpBook @HeelpBook