Don't forget "goto :EOF". Here's a more complete working fragment that can be placed anywhere in a .BAT
goto :endsubs :setpath set LOCALCLASSPATH=%LOCALCLASSPATH%;%1 goto :EOF :endsubs > Daniel Rosner wrote: > > FWIW, I was looking at the lcp.bat file and was scratching my head- I > found what it did really convenient but thought it odd that it > required a separate file. > > Obviously, it seemed to me that what you would expect is that: > > for %%i in (.\lib\*.jar) do call .\lcp.bat %%i > > could be replaced by: > > for %%i in (.\lib\*.jar) do set LOCALCLASSPATH=%LOCALCLASSPATH%;%1 > > But of course, someone else would have thought of that, and I see that > it doesn't work. Incidentally, if anyone knows WHY ON EARTH that is, > feel free to let me know... I see the behavior, but can't figure out > what is going on. > > Anyway, after poking at that, I figured out that the following does > work: > > for %%i in (.\lib\*.jar) do call :setpath %%i > > And further down in your batch file, you need a label with this code: > > :setpath > set LOCALCLASSPATH=%LOCALCLASSPATH%;%1 > > YMMV, > > -Dan
