Jump to content

Recommended Posts

Posted

Please view picture. Note: when reinstall Windows, this key will be changed.

Because I have .reg to configure my computer (every reinstall Windows, I only run .reg by one mouse click), but there are special values in this key, so I can't add this key into my .reg, because I can't use to configure if I reinstall my Windows.

question1xe.jpg


Posted

Well, it is user SID...

Easiest way is to use WMI to query the SID for specified user. In vbscript use Win32_UserAccount, in batch/cmd use

wmic useraccount where name="username_you_want" get SID

  • 1 month later...
Posted (edited)

I was looking to do something similar in C++ (get the SID for a user to access the HKEY_USERS registry key). I can't use WMI and it needs to work on Windows NT.

Any suggestions?

---Update---

I've gotten the SID using the LookupAccountName function, but am unable to access the HKEY_USERS key for any user other than the one I am currently logged in as.

More on what I am trying to do: I am trying to modify the Shell registry key for certain users that may not be currently logged in and not all users on the system.

Any ideas?

Edited by craziscoth
Posted

Getting a bit disheartened by lack of response. :(

From what I've found out so far, the HKEY_USER key isn't available for users not currently logged on. So it appears as if the SID does me no good here. The best solution I've found is to use the API LogonUser and then LoadUserProfile to load the users HKEY_USER registry key and get a handle to it.

However this requires having the user password to do the logon which I do not have. :}

Anyone know of a better solution?

  • 2 weeks later...
Posted

...or you could do one easier than that. That key IS {or at least is equivalent to} "HKEY_CURRENT_USER" (which is why if you check the msdn documentation HKCU is listed as a subkey of HKU). If you have to do it the hard way I *think* I remember seeing somewhere on msdn some function that will get the SID value. maybe you could do a search there for 'SID' or 'get SID'.

btw you'll also notice that when you make a change via the HKCU key (which has the exact same structure as the HKU\{SID #} ) that when you go back to HKU\{SID #}\whatever its value is now set to whatever you just set in HKCU.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...