# Get Logged In User Name

**URL:** <https://forums.thehomestack.io/t/get-logged-in-user-name/119>\
**Category:** vb.Net\
**Created:** [January 3, 2004, 2:07am UTC](https://forums.thehomestack.io/t/get-logged-in-user-name/119 "2004-01-03T02:07:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robinhood1995](https://forums.thehomestack.io/letter_avatar_proxy/v4/letter/r/48db29/32.png) [@robinhood1995](https://forums.thehomestack.io/u/robinhood1995)\
**Post date:** [January 3, 2004, 2:07am UTC](https://forums.thehomestack.io/t/get-logged-in-user-name/119/1 "2004-01-03T02:07:53Z")

</div>

```auto

// **************************************
    // Name: Get Logged In User Name
    // Description:Gets the name of the user logged into a Windows machine on a network.
    // By: Darrin Mason
    //
    //
    // Inputs:None
    //
    // Returns:None
    //
    //Assumes:None
    //
    //Side Effects:None
    //This code is copyrighted and has limited warranties.
    //Please see http://www.1PHPStreet.com/xq/ASP/txtCodeId.1600/lngWId.10/qx/vb/scripts/ShowCode.htm
    //for details.
    // **************************************
    
    ' If you want just the user name, use th
    // is code:
    Public Function GetUserName() As String
    GetUserName = (SystemInformation.UserName.ToString)
    // ' This will return only the user name
    End Function
    ' If you want the domain name included, 
    // use the code:
    Imports System
    Imports System.Security
    Public Module SysInfo
    Public Function GetUserName() As String
    Principal.WindowsIdentity.GetCurrent.Name
    // ' This will return 'domain\username'
    End Function
    End Module
    ' You can also call the code direct, suc
    // h as Text1.Text = (SystemInformation.Use
    // rName.ToString)

```
