LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I find the name of the windows user currently logged on?

Hi,
 
I would like to change the functionality of my program depending on who is logged on the the PC. Is this possible?
 
Thanks,
Mike
 
 
0 Kudos
Message 1 of 9
(4,898 Views)

Hello there

under windows you can use a API function to get the current user name (see attachment below). then you can change the behaviour of your app depending on the user name.

 

best regards

chris

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 9
(4,893 Views)
You can also use the %username% environment variable.
0 Kudos
Message 3 of 9
(4,885 Views)
In researching my own need for this, I came across this thread.

I also discovered that if you lay down a PROPERTY NODE from the VI SERVER palette, and set the property to APPLICATION - USER NAME, you get the user name.

Is there a reason this wasn't mentioned? Is there something I'm missing?

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 9
(4,741 Views)

hi there

the property "application:user name" returns NOT the name of the current windows user. you can set this "user name" to whatever you want with the menu item "tools->user name". 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 5 of 9
(4,722 Views)
Hi Chris,

that's interesting!

One question arises from this fact: can this property node also get faked in an executable? Normally I get the name of the current user...

Message Edited by GerdW on 08-07-2006 10:28 AM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(4,717 Views)
hi there,
 
the documentation says:
 
Available on local LabVIEW only No
Available in Run-Time Engine Yes (Read/Write)
Permissions Read/Write
 
but: i testet it with an application 7.1 (ActiveX server enabled, free access for everyone), and the property is read only! so it seems that you can't change the user name of an executable at runtime. you still can call the executable as another windows user with windows tools, but then you need the password.
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 7 of 9
(4,712 Views)
Thanks, chrisger. I see your point.

I can change the LabVIEW USER NAME to Superman, and the app:User Name reports "Superman".

However, If I build an application from the VI, even as "Superman", when the app runs, it reports my real log-in name. In other words, the LabVIEW user name did NOT get attached to the application.

I understand that it could be faked, but for my purposes, that might be sufficient.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 9
(4,700 Views)

@chrisger wrote:
 
the documentation says:
 
Available on local LabVIEW only No
Available in Run-Time Engine Yes (Read/Write)
Permissions Read/Write

This issue has been corrected in the LabVIEW 8.2 Help. If you find errors or missing information in the NI documentation in the future, you can submit product feedback at ni.com/contact.

Thank you for bringing this issue to our attention,
Kelly H.
LabVIEW Documentation, National Instruments
Kelly H
LabVIEW Documentation
National Instruments
Message 9 of 9
(4,669 Views)