Reputation: 239
I am writing a small program using C# that needs to set set the power settings for all users. This means I will need to change the Hkey Current User, and all the profiles under the Hkey Users hive. I know how to change the power settings registry keys, but I do not know how to "cycle" through all the users "profiles" (for lack of a better word) and make this change under their settings. How do I do this, or is there a better way to do this. I apologize if the scenario is not clear.
Thanks msindle
Upvotes: 3
Views: 2888
Reputation: 97848
There is no general way to edit other users' Registry settings directly. Other users' Registry settings might not even be stored on your computer. For a taste of some of the problems, read Raymond Chen's blog post, "Beware of roaming user profiles". (Make sure you understand what he has to say -- some of it applies even if you're writing an internal tool on a network that doesn't have roaming profiles enabled.)
The best solution would probably be to make a small app that makes this change for the current user, and add it to everyone's login script. That would mean your utility would change the setting every time they log in, rather than making a one-time change (so they wouldn't be able to change it back permanently), but you would be sure it happened for every user.
Upvotes: 3
Reputation: 5457
You can find a list of all profiles on the computer here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\
Each key is a profile. You can check the username by looking at the ProfileImagePath
value.
Then use the keyname and go to HKEY_USERS\[keyname]
for each user.
I'd be careful though, because you probably don't want to mess with the settings for the LocalService / NetworkService / etc users.
Upvotes: 3