kentrg11
asked on
Delete Registry Key on a remote computer
I just want to delete a registry Key on a remote Computer5, the registry key is
HKEY_LOCAL_MACHINE\SOFTWAR E\Testing
I have the code in place but keep getting "cannot write to Registry" althought i have full admin and registry rights on this PC.
Here is the code
this is domain enviroment
HKEY_LOCAL_MACHINE\SOFTWAR
I have the code in place but keep getting "cannot write to Registry" althought i have full admin and registry rights on this PC.
Here is the code
string Computer5 = TextBox2.Text;
RegistryKey key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, Computer5).OpenSubKey("Software");
key.DeleteSubKey("Testing");
key.Close();
this is domain enviroment
RegistryKey myKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "computername");
myKey.DeleteSubKey(@"SOFTWARE\test");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In my example, I'm using 2 RegistryKey variables, but you don't need to. Just add the ",true" to your opensubkey section and you should be fine.
ASKER
I have this code below as you've advised but im getting the follow error message
"Cannot delete a subkey tree because the subkey does not exist."
i confirmed there is a key on computerName called SOFTWARE/Testing
"Cannot delete a subkey tree because the subkey does not exist."
i confirmed there is a key on computerName called SOFTWARE/Testing
RegistryKey myKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName);
RegistryKey mySubKey = myKey.OpenSubKey("SOFTWARE", true);
mySubKey.DeleteSubKey("Testing");
Can you confirm that the Testing key in Software is in the HKLM not the HKCU location?
ASKER
just copy and pasted this from the remote Computer im trying to access
HKEY_LOCAL_MACHINE\SOFTWAR E\Testing
the code again is
HKEY_LOCAL_MACHINE\SOFTWAR
the code again is
RegistryKey myKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName);
RegistryKey mySubKey = myKey.OpenSubKey("SOFTWARE", true);
mySubKey.DeleteSubKey("Testing", true);
myKey.Close();
ASKER
figured it out , had to add RegistryView.Registry64);
ASKER
excellent
Sorry I was so late in getting back to this. Glad you found the missing piece! Good luck!
ASKER