🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.programmer
Article #392

Re: Current directory from batch file

#392
From: Mike Percy
Date: Fri, 04 May 1990 14:45
33 lines
1560 bytes
From article <90122.175401MCCABE@MTUS5.BITNET>, by MCCABE@MTUS5.BITNET (Jim McCabe):
> Is there any way to find out what the current directory (and current drive
> for that matter) is from within a batch file?  I am working on a program
> that changes directories all over the place, and it would be very nice
> to be able to place the user back in the original directory before terminating.
 
I am assuming you want to do something like
cd \somedir\someotherdir
program.exe
go back to first directory?

There are the pushdir and popdir functions I have seen on the net and in
various DOS utility books (e.g. PC World's Power DOS Tools), which work
well:
pushdir  /* save current dir */
cd \dir\dir   
program.exe
popdir   /* go back */
 
But the pushdir/popdir functions I have seen are either TSR's or use a
file somewher to store the directory stack.  I'd rather not do either.

DOS has a function worth thinking about - subst
subst t: \dir\dir
t:
program.exe
c:        
subst t:
 
This works well for me, since I use c: as my "home" directory, and I
seldom would have a pushdir stack more than one level deep.

Mike Percy
Technical Details
Message-ID: <8975@hubcap.clemson.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!emory!hubcap!grimlok
References: <90122.175401MCCABE@MTUS5.BITNET>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!emory!hubcap!grimlok
From: grimlok@hubcap.clemson.edu (Mike Percy)
Newsgroups: comp.sys.ibm.pc.programmer
Subject: Re: Current directory from batch file
Message-ID: <8975@hubcap.clemson.edu>
Date: 4 May 90 14:45:38 GMT
References: <90122.175401MCCABE@MTUS5.BITNET>
Organization: Clemson University, Clemson, SC
Lines: 33