title: Dynamic user home directory on Windows (changing %HOMEDRIVE% and %HOMEPATH%)
body: <h2>Actual question</h2>
  
  <p>How can I "redirect" (symbolic links?) or temporarily change the values of <code>%HOMEDRIVE%</code> and <code>%HOMEPATH%</code> (maybe based on two batch scripts that change the values when I start working at the machine and reset everything after I'm done)?</p>
  
  <h2>Background</h2>
  
  <p>A lot of Windows programs pick up either system variable <code>%USERPROFILE%</code> or a combination of <code>%HOMEDRIVE%</code> and <code>%HOMEPATH</code> in order to figure out where a user's "home" directory is that they need to use (e.g. <code>C:\Users\JohnDoe</code>). Being a fan of the philosophy of <em>portable apps</em> (see at the bottom what I mean by that), I'm wondering if I could somehow make my home directory portable, i.e. have it point to a directory on a portable device. Or, in other words, I would like to make it "dynamically changeable". </p>
  
  <h2>What I tried</h2>
  
  <p>I've read a bit about <a href="http://ss64.com/nt/set.html" rel="nofollow"><code>Set</code></a> and <a href="http://technet.microsoft.com/en-us/library/cc755104.aspx" rel="nofollow"><code>Setx</code></a> and tried this:</p>
  
  <p>Finding out what the current variable values are:</p>
  
  <pre><code>C:\Users\JohnDoe&gt; Set HOME
  HOMEDRIVE=C:
  HOMEPATH=\Users\&lt;username&gt;
  </code></pre>
  
  <p>Set them:</p>
  
  <pre><code>C:\Users\JohnDoe&gt; Setx HOMEDRIVE "d:"
  C:\Users\JohnDoe&gt; Setx HOMEPATH "\home"
  </code></pre>
  
  <p>That creates <code>HOMEDIR</code> and <code>HOMEPATH</code> as user-specific environment variables (see Control Panel >> System >> Environment Variables). But the "global ones" did not change and e.g. RStudio will not recognize the user-specific variables (still writes to <code>C:\Users\JohnDoes\[...]</code>).</p>
  
  <pre><code>C:\Users\JohnDoe&gt; Set HOME
  HOMEDRIVE=C:
  HOMEPATH=\Users\&lt;username&gt;
  </code></pre>
  
  <hr>
  
  <h2>Portable Apps</h2>
  
  <p>For example, see PortableApps.com or simply think "software that simply has been installed to a portable device instead of <code>C:\Program Files\&lt;app-name&gt;</code>". The latter works a treat for me for programs that don't really care about <code>%HOMEDRIVE%</code> and <code>%HOMEPATH%</code> (e.g. <a href="https://www.eclipse.org/" rel="nofollow">Eclipse</a> or <a href="http://www.r-project.org/" rel="nofollow">R</a>). </p>
  
  <p>Some others (e.g. <a href="http://git-scm.com/" rel="nofollow">Git</a>) just need to be tweaked a little bit (e.g. see <a href="http://danlimerick.wordpress.com/2011/07/11/git-for-windows-tip-setting-home-and-the-startup-directory/" rel="nofollow">this post</a>). </p>
  
  <p>Yet some others (e.g. <a href="http://www.rstudio.com/" rel="nofollow">RStudio</a>) run in fact smoothly off the portable device, but write stuff to the user's "home" directory. That's the kind of software that I would like to tell to use a directory on my portable device instead.</p>