How do I add a new key in the registry of other users using c# (or c/c++ or other language)
here is the scenario:
Client PC: “Administrator” account(logged in)
“User A” and “User B” can login on the Client PC only through a domain “myDomain” (they have already logged on once and have their own folder in user of the Client PC)
so I will run this code to create a new key using administrator
Registry.CurrentUser.CreateSubKey(@”SOFTWARE\myProgram\DefaultConfig”);
but the problem is, this key is only created for the “Administrator” account
I want to create this key for “User A” and “User B” too while still using “Administrator” account
both “User A” and “User B” does not appear in the HKEY_USERS
And is if there are more users in the same PC I want to add this registry key to them also is it possible to loop a code that adds a key for all users? Read and write loop?
Keys for all users are stored under the
HKEY_USERSroot key. Under this root key, there is a key for every user which has its SID as key name.You’ll have to get the SID of the desired user, then access to this root key:
But honestly, I’m not sure it’s a very good idea. Couldn’t you use
Registry.LocalMachineinstead, which applies to all users?