title: Batch script make setlocal variable accessed by other batch files
body: <p>I am writing a batch file to read a path from file and set it to environment variable. This batch file will be used (called) by many other batch files to get the variable. While writing the batch file I faced a problem will variable expansion so I used <code>SETLOCAL ENABLEDELAYEDEXPANSION</code> to overcome this issue. But doing so the other batch files which is using it are not able to get the variables set.</p>
  <p>Below is the batch script,</p>
  <pre><code>getVariables.bat
  
  @echo off
  SETLOCAL ENABLEDELAYEDEXPANSION
  if EXIST &quot;test.dat&quot; (
      for /F &quot;tokens=*&quot; %%I in (test.dat) do set %%I
      echo setting JAVA_HOME to :: !JAVA_HOME!
      echo setting JAVA to !JAVA!
  )
  </code></pre>
  <p>In my another batch file I am using the above batach file to get the variables set</p>
  <pre><code>   another.bat
   
     call getVariables.dat
     echo &quot;%JAVA%&quot;
  </code></pre>
  <p>But echo is printing &quot;&quot;, where it is not set. If this is because of <code>setlocal</code>, how can I overcome this ? I also need <code>setlocal</code> for delaying the expansion and to occur at execution time. How can I resolve this issue?</p>