Change directory for DOS window

G

Garry

I have a DOS program that must be run from its directory
and will not accept paths. It is launched by a DOS batch
file. The batch file and the DOS program are in the same
directory. The batch file can be run with a path to the
required directory. When I run the batch file from a
macro with the correct path, the DOS file will not run
because the default directory is the root directory. I
would like to write a macro that will change the DOS
directory to the correct directory then run the batch
file. I can't do a directory change in the batch file
because some of the files for the DOS program have been
pre-set to look for files in a directory designated by the
batch file. Currently I can run the batch file from the
macro, I can run command.com to open a DOS window, but I
can't change the DOS directory THEN run the batch file.

Any help would be appreciated.

TIA,
Garry
 
K

Keith Willshaw

Garry said:
I have a DOS program that must be run from its directory
and will not accept paths. It is launched by a DOS batch
file. The batch file and the DOS program are in the same
directory. The batch file can be run with a path to the
required directory. When I run the batch file from a
macro with the correct path, the DOS file will not run
because the default directory is the root directory. I
would like to write a macro that will change the DOS
directory to the correct directory then run the batch
file. I can't do a directory change in the batch file
because some of the files for the DOS program have been
pre-set to look for files in a directory designated by the
batch file. Currently I can run the batch file from the
macro, I can run command.com to open a DOS window, but I
can't change the DOS directory THEN run the batch file.

Any help would be appreciated.

TIA,
Garry

Set the path variable in the batch file, the system looks in directories
specified in path when you attempt to execute a program

example

@echo off
set origpath=%path%
path d:\pcw;%path%
ed %1 %2
set path=%origpath%
set origpath=

This saves the existing path, adds the directory of interest to the
beginning of the path,
invokes the editor, and on termination of the editor, restores the path to
what it was before
and deletes the temporary variable used to hold the original
path.directories.

Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top