Search path

K

Ken

I need to search additional paths without altering the
PATH.

path=%path%;c:\somedirectory

permanetly alters the path, but I need to search
additional paths without altering the PATH.

Thank you in advance.
 
M

Mark V

Ken wrote in
I need to search additional paths without altering the
PATH.

path=%path%;c:\somedirectory

permanetly alters the path, but I need to search
additional paths without altering the PATH.

What OS? That statement should change the PATH for the current cmd.exe
session ("window") only. To be more certain this change is limited to
the batchfile only check-out and use
SETLOCAL and ENDLOCAL commands
@echo off
SETLOCAL
set PATH=%path%;c:\somedir
ENDLOCAL
 
K

Ken

I need this for Win 98, 2000 and XP

-----Original Message-----
Ken wrote in

What OS? That statement should change the PATH for the current cmd.exe
session ("window") only. To be more certain this change is limited to
the batchfile only check-out and use
SETLOCAL and ENDLOCAL commands
@echo off
SETLOCAL
set PATH=%path%;c:\somedir
ENDLOCAL




.
 
M

Mark V

Ken wrote in
I need this for Win 98, 2000 and XP

W2K and XP but I no longer have W9x running and do not recall if
SETLOCAL is supported. (I think not). Still, a path change in a DOS
window should not effect the PATH permanently IIRC. Anyway there is
an old technique:
set oldpath=%PATH%
set PATH=%path%;c:\somedir
<do somethiing>
set PATH=%oldpath%
set oldpath=
 
M

Marty List

You don't have to use "SetLocal", it's not absolutely necessary. Even if
you do modify the PATH variable, once that instance of cmd.exe or
command.com exits, your changes are lost. All new command interpreters will
get the original PATH.

Unless you describe what you are trying to do in more detail, I don't see
why this wont work:

Set OLDPATH=%PATH%
Set PATH=%PATH%;C:\SomeProgram\
REM Do your stuff here.
Set PATH=%OLDPATH%
 
C

Charles W.

Messy but it should work.

SET PATHOLD=%PATH%
SET PATH=%PATH%;C:\whatever
Do whatever it is you are doing here
SET PATH=%PATHOLD%

Charles W.
Indus Corporation
 
T

Tim Hill

It'll work as long as he's not doing any recursive stuff, which is difficult
anyway in Win9x. :)

-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