How to get the currenlly logged in username in C#?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4040290/get-the-logged-on-user-name-in-c-sharp">Get the logged on user name in C#</a>  </p>
</blockquote>



<p>C# application may be executed either directly (double clicking on exe) or can be executed as administrator (Run as Administrator).</p>

<p>I need to run my application as administrator (Run as administrator) even in simple user account.</p>

<p>I want to get the currently logged in username using C#(But i get the username of admin). </p>

<p>i tried many options like : Environment.Username, WindowsIdentity class etc. It gives me the username of admin(because i have run the exe as admin) not the currently logged in Username.</p>

<p>This is a winForm application developed on .net 3.5. Application Executable is executed with administrator login by a vb script. vb script is executed as soos as the user logs in.</p>

<p>There are many similar queries in this fourm, but all the answers provide the username of the administrator not the currently loggeed in user's username. Hence i have posted this question. </p>

<p>please answer my query. Thanking you in advance.   </p>
