Thursday, April 23, 2009

%cd% vs. %~dp0

Until today, I also did not have an idea about the difference between these two.

%cd% available to a batch file or at the command prompt and expands to the drive letter and the path of the current directory.

%~dp0 is available to a batch file only. This expands to the drive letter and the path in which the batch file is located.

If you take the following command for an example where the batch file prints the two variables, the output would be as shown.

C:\danushka\runtime>D:\my_scripts\test_script.bat

%cd% = C:\danushka\runtime

%~dp0 = D:\my_scripts

1 comment:

Anonymous said...

It works. Thanks