From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Windows accounts & users with LabVIEW

Hello,

 

I would like to obtain the following information with LabVIEW :

 

- user account (admin or other) which is actually connected.

- user list and their own permission.

 

I don't want to use the "DOS CMD" but .net, windows dll or registry keys directly.

 

I use XP 32 bits.

 

How is it possible to get these informations?

 

 

0 Kudos
Message 1 of 8
(3,298 Views)

Here is part of what you want.

 

The outer structure decides what OS it's on, you can delete that if you're only on Windows.

 

You create a 64-byte empty string and call a Windows DLL.

 

You get back the name of the logged-in user.

 

Look around for that DLL name - you might find what else is available.

 

GetUserName.PNG

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


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 8
(3,284 Views)

You could use WMI to access this, the link below is not particularly suited to your requirement but by changing the search query (for example "Select * from Win32_UserAccount Where LocalAccount = True") and using Win32_UserAccount class members, you can get the necessary information.

 

http://forums.ni.com/t5/LabVIEW/How-to-access-WMI-Classes-via-NET-in-LabVIEW/m-p/286699#M150949

 

If you need help building the search query, you could use this: http://www.microsoft.com/en-gb/download/details.aspx?id=8572


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 3 of 8
(3,271 Views)

Thanks for the answer.

 

Indeed there are several methods to get username as yours.

 

You can get it as the screeshot or with the key registry.

 

 

0 Kudos
Message 4 of 8
(3,254 Views)

Thanks also for the WMI which I didn't know before and which can be very useful and powerful.

 

0 Kudos
Message 5 of 8
(3,253 Views)

Why not just use Application.Username?

0 Kudos
Message 6 of 8
(3,244 Views)

Why not just use Application.Username?

 

--- Read the comment on my screenshot above.

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


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 7 of 8
(3,240 Views)

Also you can access the active directories through .NET

Capture.PNG

 

The .NET 4.0 constructors have some real advantages over the 2.0 and 3.5 versions

 

Complete the following steps to force LabVIEW to load .NET 4.0 assemblies.

  1. Install the .NET Framework 4.0 on your development machine.
  2. Open a text editor and create a configuration file that contains the following text:

    <?xml version ="1.0"?>
    <configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319"/>
    </startup>
    </configuration>
  3. Save this new configuration file in the same directory as LabVIEW.exe. Name the file LabVIEW.exe.config.
  4. Relaunch LabVIEW.

"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 8
(3,238 Views)