Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6114311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:57:36+00:00 2026-05-23T14:57:36+00:00

How to change or edit registry values of other user than the current user?

  • 0

How to change or edit registry values of other user than the current user?
I know the credentials of that other user.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:57:36+00:00Added an answer on May 23, 2026 at 2:57 pm

    You can impersonate the user and then change the registry for that current context. Here are a couple of resources on C# and Impersonation:

    • Windows Impersonation using C#
    • Windows Impersonation from C#

    What you want to do is something like this (pseudo):

    using(var impersonation = new Impersonate(username,password))
    {
        ChangeRegistry(keys, values);
    }
    

    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:

    var registry = Registry.CurrentUser;
    var key =
    registry.OpenSubKey(
       @"HKEY_CURRENT_USER\Some\Path\That\You\Want\ToChange", true);
    
    key.SetValue(null, "");              
    Registry.CurrentUser.Flush();
    

    Update

    So what you need to do in order to access HKCU is that you also have to load the user profile. This is done by invoking another Win32 Method that is called LoadUserProfile. 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:

    [DllImport("userenv.dll", SetLastError = true, CharSet = CharSet.Auto)]
    public static extern bool LoadUserProfile(IntPtr hToken, 
                                             ref ProfileInfo lpProfileInfo);
    
    [DllImport("userenv.dll",  CallingConvention = CallingConvention.Winapi, 
                               SetLastError = true, CharSet = CharSet.Auto)]
    public static extern bool UnloadUserProfile(IntPtr hToken, 
                                                       IntPtr lpProfileInfo);
    

    Inside your impersonation using-block you need to do the following:

    ProfileInfo profileInfo = new ProfileInfo();
    profileInfo.dwSize = Marshal.SizeOf(profileInfo);
    profileInfo.lpUserName = userName;
    profileInfo.dwFlags = 1;
    Boolean loadSuccess = LoadUserProfile(tokenDuplicate, ref profileInfo);
    

    And after this you should be able to access the HKCU. When you’re done, you need to unload the profile using UnloadUserProfile(tokenDuplicate, profileInfo.hProfile);.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to know how to edit pyramid registry at runtime. Well i'm not
I'm trying to streamline the installation of a package that requires a registry change
I am creating an interface that allows the user to manage (among other things)
Can we change the default action of the edit selected row button? Here is
How would I change the below script to edit the original file instead of
Do I need to call edit SharedPreferences everytime before I change the preferences and
I'm trying to programatically change the text of an edit control in a 'Save
I have an HTML table where I'm building an edit function to change a
I made a small project where i try to change the name from edit
I register the following function //EDIT: updated $("#id").on("change", function() { alert('xxx'); }); In my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.