Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!bu-cs!bucsb.bu.edu!keast From: keast@bucsb.bu.edu.UUCP (Kenneth East) Newsgroups: comp.sys.ibm.pc Subject: Re: Help with directories and batch files... Message-ID: <839@bucsb.bu.edu.UUCP> Date: Tue, 17-Mar-87 21:13:39 EST Article-I.D.: bucsb.839 Posted: Tue Mar 17 21:13:39 1987 Date-Received: Thu, 19-Mar-87 03:11:38 EST References: <4471@columbia.UUCP> <838@bucsb.bu.edu.UUCP> Reply-To: keast@bucsb.bu.edu.UUCP (Kenneth H. East) Organization: Boston Univ Comp. Sci. Lines: 42 Summary: One simple way is... In article <838@bucsb.bu.edu.UUCP> madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) writes: >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 [...] >>Anybody out there have any idea how I can do this? Step one is the problem [...] > >There's really no easy way to do this (ie, DOS gives no function that ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Actually there is a very simple way to do it with I/O re-direction: 1) Create a file called cd.txt which contains ONLY the two letters 'cd' followed by a space followed by a ^Z (end of file). Let's say that we have created such a file and placed it in the directory \batch. 2) You will have to place the following in a batch file which in turn will execute your program(s). For example: REM place a 'cd ' in the file old_dir.bat copy \batch\cd.txt \batch\old_dir.bat REM append the current directory path to the same file cd >> \batch\old_dir.bat REM now you can change directories at will and execute programs, etc. cd \progs\etc foo.exe REM to return to the original directory, just execute the batch file REM you created above: \batch\old_dir.bat REM and you are back at the original directory. Please, no flames. I know it's inelegant, but it works fine, and I have better things to do than writing a "real" program to do this. -- ======================================+================================= UUCP: ..!harvard!bu-cs!bucsf!keast | ARPANET: keast@bucsf.bu.edu CSNET: keast%bucsf@bu-cs | Kenneth East @ Boston University ======================================+=================================