Remote Registry editing?
-
Is it possible with c#? I'm wanting to update registry keys from one windows service.
-
Is it possible with c#? I'm wanting to update registry keys from one windows service.
It is certainly possible to use the OpenRemoteBaseKey method of the RegistryKey class in the Microsoft.Win32 namespace to read the registry on another machine but I am not sure about updating. Both machines need to be running the Remote Registry service for this to work and must have remote administration enabled.
-
It is certainly possible to use the OpenRemoteBaseKey method of the RegistryKey class in the Microsoft.Win32 namespace to read the registry on another machine but I am not sure about updating. Both machines need to be running the Remote Registry service for this to work and must have remote administration enabled.
Yeah i got the remote viewing under control... With remote editing, I can do it with VBscript easy:
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") objReg.SetStringValue HKEY_LOCAL_MACHINE,strPointerKey,strPointerEntry,strPointerValue objReg.CreateKey HKEY_LOCAL_MACHINE,strMyKey
surely .NET can do it. this is what i tried:RegistryKey LM = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine,WSID); RegistryKey inventoryKeys = LM.OpenSubKey("SOFTWARE\\CompanyName\\AppName"); inventoryKeys.SetValue("ValueName","Value");
and the error message is: Get REG values: System.UnauthorizedAccessException: Cannot write to the registry key. at Microsoft.Win32.RegistryKey.ValidateState(Boolean needWrite) at Microsoft.Win32.RegistryKey.SetValue(String name, Object value) at testReg.Class1.update() in c:\projects\testreg\class1.cs:line 48: 03/24/20 06 02:41:01 PM -- modified at 14:58 Friday 24th March, 2006