I will simply add the below code to get username in VB.Net
Code:
System.Environment.UserName
It is very simple you know but if you want to use anymore then you can also use the below code:
Code:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name
Or else, you can also copy the below code:
Code:
Imports System.Security
Imports System.Security.Principal
AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal)
Dim myID As WindowsIdentity = WindowsIdentity.GetCurrent()
Msgbox("The Current User is : " & myID.Name)
Bookmarks