Click to See Complete Forum and Search --> : DOS batch: current directory and current drive


oob2
January 16th, 2003, 09:40 PM
Hi,

If I have a DOS batch called "a.bat" under my D:\test\a.bat. Inside this batch file, how to get the directory and drive where a.bat resides?

If I type something like this:
C:\Program Files\>D:\test\a


Thanks.

antares686
February 5th, 2003, 06:05 AM
I am confused. What are you needing the drive and directory for? The reason is given your example you have to type the drive and path to execute a. Unless it is in the current path or one of the locations sepecified in the system path settings.

oob2
February 5th, 2003, 12:55 PM
The reason is I need the a.bat to get drive and path information, and pass those information in another executable. It means I need to call another process "b.exe" inside the "a.bat", but, in "b.exe", I need to know the drive and path where "b.exe" located.

antares686
February 5th, 2003, 04:08 PM
Sorry, I recall and can find in my DOS book no command to work for relative path directly. However you can do parameters.

Ex

a.bat

%1\b.exe

b.bat

echo this is b


Now run like so

c:\pathtoa\a c:\pathtoa

a will accept the path parameter for %1 and pass onto run %1\b.exe as c:\pathtoa\b.exe

That is the only thing I remember.