thanks for the hints. My response is quite likely much too late, but I wasn't around for a while.
I have tried the environment variable %CD% that you mentioned in a batch file like this:
The output this batch file creates when called from within the directory where it is stored is as expected:
and the output when called from from the root directory is this:
I noticed that the variable is inconsistent in adding a trailing backslash as the the ending character.
CopyMyFiles.cmd is stored in C:\Scripts
At the command prompt, you change directories to F:\Data
From there you type in the command
The %CD% variable will contain the value F:\Data.
I agree with everything you say, but would you not get the same behaviour when omitting the %CD%\
from your suggested CopyMyFiles.cmd?copy data.exe c:\windows\system32\data
copy pic.jpg C:\Documents and Settings\Administrator\Desktop
I might have misunderstood the original question, but it seems to me that the question was to find a way to refer to the directory where the batch file is located (USB device?), rather than storing the batch on the hard drive.