title: Make an environment variable survive ENDLOCAL
body: <p>I have a batch file that computes a variable via a series of intermediate variables:</p>
  
  <pre><code>@echo off
  setlocal
  
  set base=compute directory
  set pkg=compute sub-directory
  set scripts=%base%\%pkg%\Scripts
  
  endlocal
  
  %scripts%\activate.bat
  </code></pre>
  
  <p>The script on the last line isn't called, because it comes after endlocal, which clobbers the <code>scripts</code> environment variable, but it has to come after endlocal because its purpose is to set a bunch of other environment variables for use by the user.</p>
  
  <p><strong>How do I call a script who's purpose is to set permanent environment variables, but who's location is determined by a temporary environment variable?</strong></p>
  
  <p>I know I can create a temporary batch file before endlocal and call it after endlocal, which I will do if nothing else comes to light, but I would like to know if there is a less cringe-worthy solution.</p>