Consider the following batch file
CD C:\SOFTWARE program.exe
This script is run from
After the script exits the current working directory is now
C:\SOFTWARE and not the previous working directory
The script changes the working directory to
config.ini which is located in
C:\SOFTWARE and locates it using the current working directory. If the software
program.exe were to be run directly from, say,
C:\ELSWHERE using its absolute path name, the program will be unable to read its config and throw an error. The solution to this is to
CD to the
C:\SOFTWARE folder first and run the program from there.
The problem with doing this in a batch file is that this also changes the working directory of the previous environment, be it the host COMMAND.COM working directory or another batch file.
This is not a problem from an NT-based command prompt which has access to
popd, along with other useful environment variables to preserve the old working directory. But is it possible to do this within the constraints of the old MS-DOS\Win9x command.com?