Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!ncar!asuvax!mcdphx!mcdchg!ddsw1!ddsw1!point!wek From: wek@point.UUCP (Bill Kuykendall) Newsgroups: comp.sys.ibm.pc Subject: Changing to and restoring directories in .BAT files Keywords: directory batch file .BAT Message-ID: <[2730.2]comp.ibmpc;1@point.UUCP> Date: 29 Oct 89 12:00:08 GMT References: <6048@gssc.UUCP> <10992@phoenix.Princeton.EDU> Lines: 26 >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