How to change or edit registry values of other user than the current user?
I know the credentials of that other user.
How to change or edit registry values of other user than the current user?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can impersonate the user and then change the registry for that current context. Here are a couple of resources on C# and Impersonation:
What you want to do is something like this (pseudo):
And when the impersonation is disposed, you are back using the running user again. Here is an example implementation of an Impersonate class that implements IDisposable to act like the pseudo-exampel shown above and here is another example.
Here is an example on how you change registry values:
Update
So what you need to do in order to access
HKCUis that you also have to load the user profile. This is done by invoking another Win32 Method that is calledLoadUserProfile. There’s a complete example here that you can use, but I’m going to include the important bits here.First you need to include the Win32 methods like this:
Inside your impersonation using-block you need to do the following:
And after this you should be able to access the
HKCU. When you’re done, you need to unload the profile usingUnloadUserProfile(tokenDuplicate, profileInfo.hProfile);.