0

In windows, I have two .bat files, say dir_a/a.bat, and dir_b/b.bat.

What I want is that after executing a.bat, I will be able to call b.bat. My approach now is to set a PATH to dir_b, so in a terminal that executed a.bat, I can just call b.bat and will be able to execute b.bat. Yet putting "set PATH=dir_b;%PATH%" in a.bat is not working. What did I do wrong?

Samzcmu
  • 15
  • 1
  • 2
  • 7

4 Answers4

2

For the case that you're dealing with a relative path: You might notice that:

set path=%path%;"\..\..\..\vc98\bin\"

will ^^ NOT work ^^ !

So do it like this:

pushd "..\..\..\vc98\bin\"
path %cd%; %path%
popd

...and of course a set path=%path%;%cd% between the pushd and popd will also do the trick

Well for also have a look here: https://stackoverflow.com/a/6595206/3135511

...
call :setAbsPath ABS_PATH ..\
...

^-To see to do it via the self made subfunction 'setAbsPath' -> or instead of call you may also use For - details in the other thread


And just a small side note for those who might also like to run Microsoft Visual C++ 6.0(anno 1998) > without install it... ... and wonder where's that f*** 'standard' include ?!

There are about 17 file in \vc98\include\ that have been manually chopped 8 + 3 chars. Like:
algrithm -> algorithm
strstrem -> strstream
xception -> exception

So be aware and creative about that !

Community
  • 1
  • 1
Nadu
  • 2,401
  • 1
  • 25
  • 30
1

You must include the absolute path to b.bat file; for example:

set PATH=C:\User A\Folder X\dir_b;%PATH%
Aacini
  • 65,180
  • 12
  • 72
  • 108
1

I suspect that you have a SETLOCAL in a.bat. ANY environment changes made after a SETLOCAL are backed out when the matching ENDLOCAL (or EOF in the same context) is reached.

Depending on how you are terminating a.bat, you'd need something in the order of ENDLOCAL&set "Path=dir_b;%PATH%"&GOTO :EOF which will prepend dir_b to your existing path as you appear to exepect for the duration of that particular CMD session.

Magoo
  • 77,302
  • 8
  • 62
  • 84
0

Don't use PATH because that conflicts with the Windows Path. Instead you could add the following:

pushd path_to_your_dir_b

Then add popd in an appropriate place

RGuggisberg
  • 4,630
  • 2
  • 18
  • 27