Remember and Recall Directory Path?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Clueless in Seattle
Posts: 47
Joined: 01 Jul 2011 13:37

Remember and Recall Directory Path?

#1 Post by Clueless in Seattle » 10 Mar 2013 17:56

I want to make a batch file in MS-DOS 6.21 that remembers the current logged drive and directory (What do you call that anyway. It's not the "path" is it?) and then re-log me back onto that drive and directory later on.

It was easy for me to simply redirect the output of the CD command to a textfile named U_R_HERE.TXT like this:

Code: Select all


But I'm having trouble figuring out how to tell MS-DOS 6.21 to log back into that drive and directory later on.

I tried this, but it didn't work:

Code: Select all

CD <e:\temp\U_R_HERE.TXT

Any ideas?
Will in Seattle
a.k.a. "Clueless"

Posts: 31
Joined: 16 Feb 2013 14:31

Re: Remember and Recall Directory Path?

#2 Post by Queue » 10 Mar 2013 19:11

Digging through some old Win9x batch files I have, I adapted a line that MIGHT work for you.

Code: Select all

echo exit|%COMSPEC% /K prompt CD $P$_|find " " > recall.bat

To restore your location, you'd use:

Code: Select all

call recall.bat

What it's actually doing is starting a new instance of, changing the prompt to ''CD CURRENT_PATH NEWLINE", echoing an exit command to that new, and parsing the new's output with find to write out a file that contains the command:

Obviously you can change the output to go to a file in a folder of your choosing.

This was adapted from an old batch to generate a %CD% environment variable, and honestly, I'm sure it could be improved, but I didn't want to tweak it too much as I'm sitting at an XP computer and am not positive I wouldn't mess things up.

Also, this was for a batch file for an older version of Windows that still used, so while I expect it to work under just DOS, I'm not certain.

Good luck!


Post Reply