Jon said:
So you could either put some code at the start of your batch file to
change
to the directory in which it is located (if that is what you want)
[For a batch file named 'somename.bat', something like this might do it
at
the start of the batch file.....
Set WD=%0
Set WD=%WD:somename.bat=%
cd /d %WD%
I'm dealing with a similar problem. I have one bat file that calls another
bat file in the same directory, but I'm not sure which directory they'll
both
be installed in. I just know they'll be in the same directory. When I run
the
first bat file as an Administrator, the current directory changes to
Windows\System32, and it can't locate the second bat file to run it. Your
code example above returns the complete path to the bat file from the %0
parameter, including the bat file name itself. E.g.
C:\users\moralejf\documents\master.bat.
How can my bat file truncate this path to remove the bat file name, so as
to
get only the directory path, e.g. C:\users\moralejf\documents? The
Set WD=%WD:somename.bat=%
line in your example is very mysterious to me, but if it is intended to
truncate the bat file name, it doesn't succeed in doing so (even if I
change
somename.bat to the actual bat file name). Thanks in advance, Joseph