How to use special batch DOS parameters (DOS programming)

Send Us a Sign! (Contact Us!)
Word PDF Epub XPS

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).

Batch DOS Parameters

Batch DOS Parameters

The following table lists possible combinations of modifiers and qualifiers that you can use to get compound results.

Batch DOS Parameters combination

Batch DOS Parameters combination




1 thought on “How to use special batch DOS parameters (DOS programming)”

Comments are closed.