title: Script calling batch file that sets environment variables
body: <p>I need to write a script, on Windows, that calls a batch file to set some environment variables, then carries out some actions that make use of those environment variables.</p>
  
  <p>If the calling script is itself a batch file, this works fine.</p>
  
  <p>There would be some advantages to being able to write the calling script in Python, but when I try that, the environment variables set by the batch file don't persist after it returns. I'm guessing that's because <code>subprocess.check_call(..., shell=True)</code> spawns a fresh copy of the command shell, which takes the environment variables with it when it dies at the end of the batch file.</p>
  
  <p>Is there a way to get the environment variables to persist when set by a batch file called from Python, or is it better to resign oneself to the calling script being itself a batch file?</p>