Archive: How to find all users names


How to find all users names
I want to delete files from <sys_disk>:\\Documents and Settings\<user_name>\Application Data\MyProgDir
But $Appdata allows to delete only from AllUsers and CurrentUser. Is it possible to find all other user names without any plugins (maybe some registry values can store all users names)?


i think this is hard without using a plugin, u could go thru the keys in HKEY_USERS (except .default) but im not sure if only admins can read this key

ex: HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\AppData



Get users profile folders name (2000/XP)


Thanks, Instructor! Very useful code.


that code is useful but what if one of the users changes the location of their special folders by editing the registry in hkey_current_user or using some windows tweak utility?

currently, i can't find a way to obtain each user's special folders which is interesting since removing user-specific data on an uninstallation would seem desirable.


Originally posted by jpodtbc
that code is useful but what if one of the users changes the location of their special folders by editing the registry in hkey_current_user or using some windows tweak utility?
I suppose if one of the users has changed the location of his/her profile, the registry key where Instructor's code searches should be updated as well.

Just came across this while looking for a similar solution and here is another method for deriving the user name only (which can then be inserted into the relevant folder path): Use EnumUsersReg and in the callback function simply query the HKU registry value:

Software\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}
Reading the value of REG_SZ Username.

Or, if you are only interested in %APPDATA% for that user, simply read in the EnumUsersReg callback the value of REG_SZ AppData in (HKU):
Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HTH