How can I change the windows USERNAME environment variable string?
<p>I am looking for a solution for this after struggling for most of the day.  In short my dilemma seems simple.  An effective solution appears elusive based on the Google and Stackoverflow <em>hits</em> I've had on this one.</p>
<blockquote>
<p>(<em>EDIT</em>) <br/> I need to clarify the use-case.  We may have 6 users needing to run certain scripts that use the &quot;<code>%USERNAME%</code>&quot; string to login to case-sensitive environments, Linux, MySQL, etc.  One user-name is <em>mixed-case</em>.  In the example I used my name: &quot;Will&quot; for the scripts it must-be: &quot;will&quot; (all lower-case).</p>
<ul>
<li>The general question though is how can the %USERNAME% environment variable value be change when it is <em>mis-entered</em>?</li>
</ul>
</blockquote>
<p>At present my Windows 7 Professional username is &quot;will&quot; but the environment variable has this value:</p>
<pre><code>echo.  User = %USERNAME%
  User = Will
</code></pre>
<p>I need it to come-out as:</p>
<pre><code>  User = will
rem      * All lower-case
</code></pre>
<p>To be clear ...</p>
<blockquote>
<p>I want to change (source) value Windows sets the USERNAME environment variable when I login.</p>
</blockquote>
<p>I thought it would be <em>easy</em> to find the setting or config option to change that string -- Until I tried.  I think this must happen frequently judging from questions related to getting a USERNAME to work with cygwin, etc.</p>
<p>The question</p>
<ul>
<li><a href="https://stackoverflow.com/questions/284776">How to convert the value of %USERNAME% to lowercase within a Windows batch script?</a></li>
</ul>
<p>Bothers me too, because that's a messy script to &quot;<em>fix</em>&quot; something basic in a login-environment.</p>
<p>I did a quick survey around the office as well.  Some people have mixed case, one or two have lowercase.  It seems arbitrary depending on what was typed-in when  account was created or something.</p>
<p>Our admin guy looked up my account on the domain (no, not active directory) and is same as my login-screen, &quot;will&quot; (lowercase).</p>
<p>Finally I did a couple of experiments.  I changed my username in the Users control panel</p>
<pre><code>from:  &quot;will&quot; to &quot;xxwill&quot;
</code></pre>
<p>Thinking that would surely update my USERNAME string.  I logged out. I did it again and rebooted a second time.  The result was extremely surprising (or maybe it shouldn't have been):</p>
<pre><code>  User = Will
rem      * NO change for the &quot;xxwill&quot; name-change!
</code></pre>
<p>Some further grist.  I created an account &quot;dodo&quot; and account &quot;Dogdo&quot; and changed the usernames to &quot;Dodo&quot; and &quot;dogdo&quot; respectively.</p>
<pre><code>  User = dodo
  User = Dogdo
rem      * NO change for name-changes!
</code></pre>
<p>I see that the USERNAME can't be altered that way.  I can't edit the system environment variable in the Advanced options.  It may be in the profile.  But can you edit a profile or even look <em>inside</em> it with just Administrator powers?  I don't know yet; I'm not sure that's my preferred route either since it is hacking with a bit of &quot;output&quot; from some original setting, <em>somewhere</em>.</p>
<p>I hope someone can set me straight so I don't need that script-solution.</p>