Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!husc6!think!ames!amdcad!sun!imagen!qubix!wjvax!mario From: mario@wjvax.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: Batch file processing Message-ID: <1160@wjvax.UUCP> Date: Thu, 3-Dec-87 10:39:31 EST Article-I.D.: wjvax.1160 Posted: Thu Dec 3 10:39:31 1987 Date-Received: Wed, 9-Dec-87 06:23:28 EST References: <3985@bellcore.bellcore.com> Reply-To: mario@wjvax.UUCP (Mario Dona) Distribution: na Organization: Watkins-Johnson Co., San Jose, Calif. Lines: 36 Keywords: batch, how to save directory 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.