devxlogo

Get login information the easy way (without any API call)

Get login information the easy way (without any API call)

While you can use many different API function to get user and domain information, if you’re running under Windows NT or 2000 Server there is a shortest path, based on the fact that the operating system loads many piece of data into environment variables:

' this code works only under Windows NT and Windows 2000 ServerDebug.Print "Computer Name: " & Environ$("COMPUTERNAME")Debug.Print "Logon Server: " & Environ$("LOGONSERVER")Debug.Print "User Domain: " & Environ$("USERDOMAIN")Debug.Print "User Name: " & Environ$("USERNAME")

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist