What is the best way to enumerate all of the user profiles on a computer?
I know how to get the currently logged in user profile, and I know how to get the "all user" profile. But I'd like to get a list of each and every profile on the computer.
Open Computer Management, and go to “Local Users and Groups -> Users.” On the right side, you get to see all the user accounts, their names as used by Windows behind the scenes, their full names (or the display names), and, in some cases, also a description.
Use Get-LocalUser PowerShell cmdlet to List All User Accounts. The Get-LocalUser PowerShell cmdlet lists all the local users on a device.
Step 1- Open the Command Line Interface by running "cmd" in the run dialog box (Win + R). Step 2- Type query user and press Enter. It will list all users that are currently logged on your computer.
Before going the undocumented route like flokra suggests, I would try NetUserEnum() or NetQueryDisplayInformation()
If you want to go into undocumented land, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
has a (incomplete) list of accounts (It's missing special accounts like ASPNET, HelpAssistant and SUPPORT_xxxx) It also has the path to the profile folder, which is a lot safer than using %ALLUSERSPROFILE%\..\
but why use it when there is GetProfilesDirectory()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With