mrwittma@phoenix.Princeton.EDU (Martin R. Wittmann) (10/21/89)
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? NOTE: I have two programs called pushdir and popdir, but they are unsuitable because they leave memory resident stubs at inconvenient memory locataions. For instance, if I want to change to a directory and invoke a TSR removal program and then change back to the original directory, pushdir leaves a stub above the TSR, so it can't be successfully removed. Related batch file questions: can I set an environment variable to the current directory name? Can I write a program which can change an environment variable which is exported back to the parent shell (i.e. so the change does not disappear when the program exits)? Thanks! martin wittmann
wek@point.UUCP (Bill Kuykendall) (10/29/89)
>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 environment to the string that is piped to it. Executing the CD command with no argument will echo the current directory, so: CD | SETVAR CURDIR will set the variable CURDIR to the current directory. Hint: If you need the current drive in a separate variable, do: CD \ CD | SETVAR CURDRV Setvar is shareware. You can get it from nearly any PD archive. If you can't find it, let me know. --------------- Bill Kuykendall Chicago, IL USA ...!point!wek wek@point.UUCP
Ralf.Brown@B.GP.CS.CMU.EDU (11/03/89)
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."
kevinc@cs.AthabascaU.CA (Kevin Crocker) (11/10/89)
In article <[2730.2]comp.ibmpc;1@point.UUCP>, wek@point.UUCP (Bill Kuykendall) writes: > >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 > Bill Kuykendall PUSHDIR and POPDIR do exactly the same thing without all the piping. They were PD, at least the ones I have were. I have`nt upgraded them or even know if they are upgradeable -- don't fix what ain't broken! Kevin -- Kevin "auric" Crocker Athabasca University UUCP: ...!{alberta,ncc,attvcr}!atha!kevinc Inet: kevinc@cs.AthabascaU.CA