title: Getting the logged in user of a Windows computer VB.NET
body: <p>My program depends on information that changes depending on which user is logged in. An example would be the location of AppData. My program also needs Administrative privileges. If I run the program as Administrator, the program thinks the Administrator is the currently logged in user.</p>
  
  <p>My "solution": Create a second program to run as console. It runs as a standard user, putting information into variables to correctly identify the current user. It then save the main program, from Resources, to disk, starts it, then passes these variables via Arguments.</p>
  
  <p>The problem: I have to Build the program twice before I can test it. This is very annoying.</p>
  
  <p>Although my solution works, I'm tired of it. Is there any other way I can get the currently (active) logged in user? I've tried <strong>SystemInformation.UserName.ToString</strong> and <strong>My.User.Name.ToString</strong>. Both give the wrong user.</p>
  
  <p>Edit: <strong>System.Security.Principal.WindowsIdentity.GetCurrent().Name</strong> does not work.</p>
  
  <p><strong>Proposed Solution:</strong> Instead of having a program run before my main program to gather information, I will try to have that program run at the same time my main program does. My main program will wait until the information has been sent back, and then resume. This way, I don't have to double build all the time.</p>