mario@wjvax.UUCP (Mario Dona) (11/30/87)
I have an annoying problem that I hope someone has a solution to. I have this batch file which executes a BASIC program. All this BASIC program does is display a message on the screen (in appropriate colors and in reverse video). The batch file, of course, can be executed from any directory, but what I want it to do is to return to the directory it was called from. All I can get it to do is exit to the directory which contains the batch file itself. I'm running DOS 3.2 on a true-blue IBM AT. Any ideas would be greatly appreciated.
hundt@wind.bellcore.com (tom hundt) (12/03/87)
In article <1156@wjvax.UUCP> mario@wjvax.UUCP writes: > The batch file, of course, can be executed from any >directory, but what I want it to do is to return to the directory it was >called from. All I can get it to do is exit to the directory which contains I seem to have no problem getting a batch file to end anywhere I want to; just by putting CD \WHEREVER at the end. If you want to AUTOMATICALLY return to wherever you were when you ran the batch file, (presumably the batch file being somewhere in your search path), you need to save and restore the directory context. There is a set of programs PUSHDIR and POPDIR which do just that. What you do is put PUSHDIR at the beginning, then CD wherever you want, and when it hits the POPDIR you put at the end, back you go where you started at. It's public domain, and I can post if anyone's interested. (I'd send it to the .binaries group if someone can tell me this week's procedure :-) ) /-^-\ Thomas M. Hundt / BELLCORE Morristown NJ / hundt@bellcore.bellcore.com | | {seismo|ihnp4|ucbvax|decvax|ulysses|allegra|clyde}!bellcore!hundt /--_--\
mario@wjvax.UUCP (12/03/87)
In article <3985@bellcore.bellcore.com> hundt@wind.bellcore.com (tom hundt) writes: >I seem to have no problem getting a batch file to end anywhere I want to; >just by putting CD \WHEREVER at the end. > >If you want to AUTOMATICALLY return to wherever you were when you ran >the batch file, (presumably the batch file being somewhere in your search >path), you need to save and restore the directory context. There is a set >of programs PUSHDIR and POPDIR which do just that. What you do is put >PUSHDIR at the beginning, then CD wherever you want, and when it hits the >POPDIR you put at the end, back you go where you started at. > >It's public domain, and I can post if anyone's interested. (I'd send it >to the .binaries group if someone can tell me this week's procedure :-) ) > Thanks to all who responded to my question on getting batch files to return to the directory it was executed from. Tom Hundt's solution sounds very promising, and I for one would like to see PUSHDIR and POPDIR posted in this group. But lacking these two programs, I tried a solution which was suggested by many others. Below is Ryan Gale's suggestion for the benefit of others with similar experience. Well, my first thought is that the "of course" here isn't warranted; it can do this only because you've set your PATH accordingly. However, since you _have_ set your PATH, try this: [drive:][path]BASIC [drive:][path]PROGNAME.BAS In my case, it would likely be E:\UTIL\DOS\BASIC D:\BASIC\SOURCE\FOO.BAS. Of course, if BASIC is on the path, you can eliminate that part: BASIC D:\BASIC\SOURCE\FOO.BAS This will run the program and return you to where you were when you invoked it -- because you *never left* the directory you invoked it from.