Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

How 2 add directory to PATH from command line (Users)

posted by Arjay, 07.01.2013, 18:05

> Is there a command in MS-DOS 6.21 that I can use to temporarily "insert" or
> "add-on" a directory to the existing PATH statement?

I am not near a PC, so from memory:
set oldpath=%path%
path=%path%;c:\testdir1;c:\testdir2
[do testing]
path=%oldpath%
set oldpath=

First line will backup the path to a temporary environment variable (providing you have room in the environment, if not you can always expand it). Second line adds 2 new directories onto the end of the path. Do testing line speaks for itself, 3rd line restores original path and 4th line removes temporary oldpath variable. Depenfing on what your doing not all the lunes ate required and a quick trick is to start a new command.com session, change the path then just do an exit when done.

Most of my batch files were designed to not require external programs if I could help it hence until you mentioned append I'd completely forgotten about it. A simple way of checking if the environment is big enough to backup another copy of the path is to do an if check like this:
if NOT "%path%"=="%oldpath%" goto PATHERROR

Re your autoexec.bat question I used to make mine runable again by doing a simple check if it had already run, e.g
if NOT "%booted%"=="" GOTO rerun
:firstrun
set booted=1
rem do 1st boot stuff e.g load keybd tsr
goto end

:rerun
set path=c:\dos;c:\bcc
goto end

:end
> The reason I want to do this is to try out a program. So I don't want to
> update the path statement in my AUTOEXEC.BAT file until I decide whether or
> not I'll continue to use this new program.

 

Complete thread:

Back to the forum
Board view  Mix view
22762 Postings in 2122 Threads, 402 registered users (2 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum