Ugh. I’m pressing the limits of the MS-DOS command system here, I think.
I need to make a .bat file that stores the current directory, switches to another directory based on what flavor of Windows we’re on (NT-based or 9x), runs an executable, and changes back to the original directory.
So far, I know how to run the executable. I’m pretty well stuck with the .bat format due to various issues. Any help?
Do you really need to change the directory? Unless the program you’re running needs some external files in the same directory you can either provide a fully qualified path to the .exe or make sure it’s in your Path environment variable. Then you can run the program and still be in the directory you started from.
On Win2K (and XP?) you can use the built-in variable CD, e.g. set olddir=%CD%, followed by cd %olddir% later. On Win9x, this page explains how to achieve the same result.