Solution
There are three methods could be used to retrieve Windows username in LabVIEW.
Method 1
If you only need the Windows username, then the following instruction will suffice:
- In the block diagram, place a VI Server Reference.

- Click the VI Server Reference, then select This Application.

- Connect the output reference to a property node.

- Click the property node to select Application>>User Name

- Connect a string indicator to the property's output to display the user name.

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
Method 2
If you would like to include the domain along with the Windows username in the resulting string, then the following instruction will be best:
- Insert an Invoke Node (.NET) into the block diagram

- Right-click the invoke node and select Select Class>>.NET Framework>>Browse

- In the Select Object from Assembly window, select mscorlib from the Assembly drop-down menu

- Scroll down the Objects list and double-click the System.Security.Principal to expand it

- Select WindowsIdentity and click OK

- Right-click the invoke node and select Select Method>>[S]GetCurrent()

- Connect a property node to the reference output of the GetCurrent method

- Right-click the property node and select Select Property>>Name

- Connect a string indicator to the property's output to display the user name with domain information

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.