List All User Accounts

Post new topic   Reply to topic

View previous topic View next topic Go down

List All User Accounts

Post  conorsteel on Sun Aug 31, 2008 3:07 pm

This will return a list of all users in a computer.

Make sure to have "Imports System.Management" at the beginning of any code file this is in.
If you need to, add a reference to System.Management.dll

WARNING: Hidden users such as Guest and Administrator and other miscellaneous accounts my be in your computer.

CODE
Private Function AllUsers() As String()
Dim R As New List(Of String)

Dim query As New SelectQuery("Win32_UserAccount")
Dim searcher As New ManagementObjectSearcher(query)

For Each envVar As ManagementObject In searcher.Get()
R.Add(envVar("Name"))
Next

Return R.ToArray
End Function

conorsteel
Admin
Admin

Number of posts: 13
Age: 16
Location: Kilmarnock, Scotland
Registration date: 2008-08-31

View user profile http://homefinanceviewer.webs.com

Back to top Go down

View previous topic View next topic Back to top


Permissions of this forum:
You cannot reply to topics in this forum