Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
4 ratings:
 4.75 out of 5     Rate this Document

Programmatically Retrieve Windows User Name in LabVIEW

Primary Software: LabVIEW Development Systems
Primary Software Version: N/A
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
I would like to build a path constant specific to the currently logged-on user.  For example, I would like to create files on the user's desktop, and the path to the desktop contains the Windows user name.  Is there a way to get the Windows user name from LabVIEW?

Solution:
One way to obtain the Windows user name is by using the System Exec function in LabVIEW.  A full list of Windows Environment Variables may be obtained by typing set at the command prompt.  To return any of the Environment Variables, use the command echo %EnvironmentVariableName%.  Use the command echo %username% with the System Exec function to programmatically get the Windows user name in LabVIEW.

Another way to obtain the Windows user name is by using the User Name property of the Application class in VI server.

Both techniques result in the same string.



Related Links:
KnowledgeBase 4B1M2AC: Programmatically Retrieve User Name In TestStand
KnowledgeBase 2C7F28O9: Error 2 (Memory Full) When Using the System Exec VI

Attachments:





Report Date: 01/29/2009
Last Updated: 01/08/2010
Document ID: 4TSGQEYP

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit