Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HKEY_USERS contains only logged in users

Tags:

c#

windows-8

I am writing a c# application.

As part of my application, I need to read the users' profiles.

In order to get all the users, I am using Registry.Users.GetSubKey().

The problem is that on Windows 8 the HKEY_USERS contains only logged in users! (when there is 2 users logged in I wiil see 2 users under HKEY_USERS, but if one of the users will sign out, then there will be only 1 user under HKEY_USERS)

As a result, I get the profiles only for logged in users.

I tried to search the entire registry to find where the data is saved, but I can't find this information anywhere.... it seems like the info is gone when the user logs out.

Is it by design, or a bug?

Where the data is saved - it must be in the registry, but I can't find it...

Could it be something in the permissions? Maybe the info is there but it's hidden when the user is not logged in? Is there a flag or something I can use to read the profile for non logged in users?

like image 750
user844541 Avatar asked Jul 11 '12 11:07

user844541


2 Answers

This may not work in all cases, but has suited my needs. Load Registry Hive

reg load HKU\Steven C:\Users\Steven\ntuser.dat

Read necessary data, then unload

reg unload HKU\Steven
like image 192
Zombo Avatar answered Oct 06 '22 18:10

Zombo


As part of my application, I need to read the users' profiles.

Then you need to redesign your application. What you're asking for is not possible.

From Raymond Chen's blog post, "Beware of roaming user profiles":

[Y]ou cannot just cruise through the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList registry key expecting to find all the user profiles and possibly even modify them, because the copy of the user profile on the local computer might not be the authoritative one.

Anything you see on your local machine relating to other users' profiles -- whether under HKEY_USERS, or in their profile directories under C:\Users -- is just a local cache from the last time they logged in on that machine. The real data, the up-to-date data, is stored on a domain controller somewhere.

You can't rely on other users' locally-stored profile data for anything at all. You're better off pretending it's not even there.

like image 39
Joe White Avatar answered Oct 06 '22 16:10

Joe White