title: Pass environment variable through Windows Explorer
body: <p>I want to set an environment variable, and then spawn a Windows Explorer window in such a way that processes launched from this new Explorer window inherit that environment variable. I want to do this, so that a diff tool I am integrating with the TortoiseSVN shell extension has access to project-specific environment variables set in a project startup script. But the obvious ways of doing this seem to lose the environment variable somewhere:</p>
  
  <ol>
  <li>launch cmd.exe</li>
  <li><code>set MYVAR="foo"</code></li>
  <li><code>set | findstr MYVAR</code></li>
  <li>Result contains MYVAR="foo"</li>
  <li><code>explorer .</code></li>
  <li>From the resulting Explorer window, Shift+Right-click a folder and choose "Open Command Window Here"</li>
  <li><code>set | findstr MYVAR</code></li>
  <li>Result does not contain MYVAR</li>
  </ol>
  
  <p>I have set my Windows Explorer settings to <a href="http://winaero.com/blog/how-to-start-explorer-in-a-separate-process-in-windows-8-1-windows-8-and-windows-7/" rel="nofollow">spawn a new process for each Explorer window</a>, hoping that would help, but it seems to have no effect.</p>
  
  <p>I can use <code>setx</code> instead of <code>set</code> to store the variable globally, however if I want multiple windows to have different versions of MYVAR (e.g. if I'm working on multiple projects at once), this will not work.</p>
  
  <p>Is there a way to set an environment variable specific to a Windows Explorer window, which will be inherited by all its child processes?</p>