Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!pt.cs.cmu.edu!b.gp.cs.cmu.edu!Ralf.Brown@B.GP.CS.CMU.EDU From: Ralf.Brown@B.GP.CS.CMU.EDU Newsgroups: comp.sys.ibm.pc Subject: Re: Changing to and restoring directories in .BAT files Message-ID: <255185fb@ralf> Date: 3 Nov 89 11:35:07 GMT Sender: ralf@b.gp.cs.cmu.edu Organization: Carnegie Mellon University School of Computer Science Lines: 31 In-Reply-To: <[2730.2]comp.ibmpc;1@point.UUCP> In article <[2730.2]comp.ibmpc;1@point.UUCP>, wek@point.UUCP (Bill Kuykendall) wrote: >>From within a .BAT file, I would like to be able to save the current >>directory, change to a new directory and then change back to the >>original directory before exiting the .BAT file. Is there a straight- >>forward way to do this? > >SETVAR will do what you need. It will set a variable in the original 1. Install 4DOS in place of COMMAND.COM start the batch file with "PUSHD directory-to-run-in" end the batch file with POPD 2. get PC Mag's PUSHDIR/POPDIR combo. run PUSHDIR in AUTOEXEC.BAT to install the resident portion use PUSHDIR again at the start of the batch file change to the desired directory and do your work use POPDIR at the end of the batch file I used to use #2, and now use #1. Both work fine (and 4DOS is a case of "how did I ever do without"--it makes the command interpreter what COMMAND.COM *should* have been, and significantly enhances batch files). -- UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=-=-=-=- Voice: (412) 268-3053 (school) ARPA: ralf@cs.cmu.edu BIT: ralf%cs.cmu.edu@CMUCCVMA FIDO: Ralf Brown 1:129/46 FAX: available on request Disclaimer? I claimed something? "How to Prove It" by Dana Angluin 6. proof by omission: "The reader may easily supply the details." "The other 253 cases are analogous."