Adding to search path

K

Ken

I know to permanently change the search path in DOS use

path=%path%;c:\someprogram\

but how do you do a non-permanent search? Can I use the
APPEND command. What I want to do is search the regular
PATH and additional paths without altering the original
PATH.

Thank you in advance.
 
M

Marty List

Define what you mean by"search". Are you trying to launch a program, and
let the OS search for it in the path, or are you really searching the path
yourself?

The simplest option may be:

SetLocal
Set OLDPATH=%PATH%
Set PATH=%PATH%;C:\SomeProgram\
:: Do you stuff here
Set PATH=%OLDPATH%
 
T

Tim Hill

Any change made is local to the current shell session. So you can either use
setlocal/endlocal to bracket the changes, or invoke a different CMD.EXE
instance to do the work.

Example:

setlocal
set PATH=c:\foo;%PATH%
(do some stuff)
endlocal

-Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top