I want a batch file to be able to reference its own location in the folder
tree.
I create the file C:\FOOBAR\MYSELF.BAT:
@echo off
echo This batch file is in folder %CD%
pause
This returns, as expected, the following output:
This batch file is in folder C:\FOOBAR
However, if I launch the file by dropping another file onto it, I get this:
This batch file is in folder C:\Documents and Settings\David
which is my home directory.
How can I capture the actual physical location of the batch file even when
it is launched by having a file dropped on it?
Special bonus question: Why does the command-line interpreter behave in this
way?
Thanks.
David
|