Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!mit-eddie!bu-cs!bucsb.bu.edu!madd From: madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) Newsgroups: comp.sys.ibm.pc Subject: Re: Help with directories and batch files... Message-ID: <838@bucsb.bu.edu.UUCP> Date: Tue, 17-Mar-87 19:54:50 EST Article-I.D.: bucsb.838 Posted: Tue Mar 17 19:54:50 1987 Date-Received: Thu, 19-Mar-87 03:05:46 EST References: <4471@columbia.UUCP> Reply-To: madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) Organization: ODO (Organization for the Disorganization of Organization) Lines: 57 In article <4471@columbia.UUCP> x1.micky@cu20b.columbia.edu (Micky Liu) writes: >I am trying to use a batch file to: > >1) save the current directory >2) goto another directory >3) execute some program >4) return to saved directory > >I'm having a great deal of trouble trying to get PC-DOS 3.1 to do this. [...] >Anybody out there have any idea how I can do this? Step one is the problem >here. In the manual it says that DOS remembers the original directory, but >it doesn't return to the original directory at the end of the batch file. I >tried to write a program to put something in the environment, but that is no >good since when the program terminates the newly modified environment goes >with it... There's really no easy way to do this (ie, DOS gives no function that can do it). What you need to do is either get hold of some program that inplements directory stacks (there's a pd program pair pushdir and popdir that would work) or to write a program to save the old directory into a file (or write a simple shell program, which is more involved). If you can get hold of pushdir/popdir, you can do the following batch file: rem save the old dir and switch to the new dir pushdir \newdir\that\you\want rem run program program rem return to old directory popdir You can write a real simple pushdir/popdir pair yourself by saving the current directory in a file and having popdir retrieve it. The programs are simple enough to write that I leave it as an exercise to the reader. Besides, I have no idea what kind of languages you use. The fastest method (execution wise) is to create a shell program that gets the current directory, saves it in a string, does a chdir to the new directory, exec's the program you want to run, then does a chdir back when the program gives control back. This takes memory, however (although only a few bytes if you write it in assembler). If you want pushdir/popdir, you should first try asking friends. A surprising number of people have these. If nobody does, then look around the larger bbs's. They probably will (I've seen it on several -- one of them is a bbs sponsored by Systems House in Laconia NH, phone (603) 524-1000, which just happens to be the only one that I know the number of off the top of my head). These programs are real short, so they don't take too much time to download. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - Jim Frost * The Madd Hacker - UUCP: ..!harvard!bu-cs!bucsb!madd | ARPANET: madd@bucsb.bu.edu CSNET: madd%bucsb@bu-cs | BITNET: cscc71c@bostonu -----------------------------------+-----+------------------------------ "New minds, fresh ideas -- be tolerant." | _@o. <- Mick the Micro Mouse