Hi, I new in this forum, I have a little experience with C#.
I need to write an application that can add/delete registry keys in a remote server.
I'll explain my self. I working in a company that have a lot of servers and sometimes we need to add/delete keys to the servers, currently this is made manually, but this time a lot of time.
I want to write an application that, I can tell it to with remote server to insert/delete the key.
Is this possible? I found examples to add/delete registry keys, but in a local machine.
Thanks for your help

Dani AI

Generated

Short answer: yes — if you have administrative rights on the targets and the machines are configured to allow remote registry access. pointed you in the right direction and confirmed it works; the next important steps are to make that work reliably and safely across many servers.

Things to check before running mass updates:

  • The process runs under an account that is an administrator on each target (the remote-registry APIs use the caller's security context). If you must supply alternate credentials, run the tool under that account or perform explicit impersonation / network connection before touching the registry.
  • The Remote Registry service must be enabled and running on the targets, and the firewall must allow the remote-management/RPC endpoints used by the API.
  • On newer Windows versions, remote UAC (token filtering for local accounts) can block administrative operations from networked processes; prefer domain accounts or handle the LocalAccountTokenFilterPolicy carefully.
  • Watch 32-bit vs 64-bit registry views (Wow6432Node). Run with matching process bitness or use the RegistryView APIs on newer .NET runtimes.
  • Always test on one machine first and back up keys before deleting.

Example pattern (C#) — connect, create/set a value, and delete a subtree:

using Microsoft.Win32;

using (var hklm = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "TARGETHOST"))
{
    using (var key = hklm.CreateSubKey(@"SOFTWARE\MyCompany\MyApp"))
    {
        key.SetValue("Flag", 1, RegistryValueKind.DWord);
    }

    // to remove an entire key tree (be very careful)
    // hklm.DeleteSubKeyTree(@"SOFTWARE\MyCompany\MyApp");
}

If the goal is to update many servers, consider safer deployment alternatives: Group Policy Preferences for registry changes, PowerShell Remoting (Invoke-Command) with credentials, or a configuration-management tool (Chef/Ansible/DSC). Add robust error handling, logging, and an undo/backup plan before running deletes.

Recommended Answers

All 4 Replies

I don't even know .net and I can tell you this isn't possible. What a security nightmare this would be if it were possible.

Also if you have administrator permissions? Remember I'm talking remote severs that I have administrator permissions
Thanks

Thanks, I use "OpenRemoteBaseKey" and is working fine

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.