title: How to maintain environment variables of a bat file before executing another program in a bat file?
body: <p><a href="https://stackoverflow.com/questions/1103994/how-to-run-multiple-bat-files-within-a-bat-file">A way to run multiple programs in a bat file.</a></p>
  
  <h2>Objective</h2>
  
  <p>Distribute a software with GDAL as a dependency. </p>
  
  <p>To do that I have downloaded gdal binaries from <a href="https://www.gisinternals.com/release.php" rel="nofollow noreferrer">GIS Internals</a>. The downloaded data has a <code>.bat</code> file to set environment variables. It uses <code>set</code> command to set the environment variables.</p>
  
  <p>As per my limited knowledge in windows bash scripting, I understand that the environment variables set by <code>set</code> are limited to current command prompt itself and are reset when a new command prompt is launched.</p>
  
  <p>Also, is it true that a calling a batch file from a batch file launches new command prompt which when closes doesn't affect the next command called in the parent script.</p>
  
  <p>There is another issue here - will the environment variables affect the process created (such as calling gdal_translate) by a Java program? If it doesn't, then there is no point in setting local environment variable.</p>
  
  <hr>
  
  <h2>Final Requirement:</h2>
  
  <p>How to use the environment variables set in another batch file (called from a batch file) in the next line of the parent batch file, without using <code>setx</code>?</p>