Guest Jonny Posted January 8, 2009 Posted January 8, 2009 I have been trying to add a readonly permission to a key in in HKLM using the following code (simplified) ================================ RegistrySecurity security = new RegistrySecurity( ) security.AddAccessRule( new RegistryAccessRule( Read ) ) RegistryKey key = RegistryKey.OpenRemoteBaseKey( HKLM, "computer" ) key = key.OpenSubKey( @"SOFTWARE\Test", true ) key.SetAccessControl( security ) ================================ This currently throws the following error "The supplied handle is invalid. This can happen when trying to set an ACL on an anonymous kernel object" If I modify the code to perform the task on the local machine everything is fine. I'm guessing the security token is not being initialised from my local machine. I've added Impersonation code around and this did not help. Is it possible to remotely change registry permissions using managed code? or do I have to revert to P/Invokes? Thanks /J -- /Jonny Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.