Issue Setting Remote Registry Key Value
-
All, I am attempting to write a new Remote Registry key Value string, but I keep receiving a "Cannot write to the registry key" exception. I have full access to the remote key and have set that access (as an extra measure) inside my program. Below is the code I an attempting to use. I can read the value fine, but cannot edit it. Thoughts?
bool SetRegKey(String hostname, String strPrimaryUserGroup) { String strBaseKey = "Software\\Agent"; RegistryKey environmentKey = RegistryKey.OpenRemoteBaseKey( RegistryHive.LocalMachine, hostname).OpenSubKey( strBaseKey); String PUGValue = environmentKey.GetValue("PrimaryUserGroups").ToString(); if (PUGValue != strPrimaryUserGroup) { environmentKey.SetValue("PrimaryUserGroups", strPrimaryUserGroup); } return false; }