Reputation: 670
I am creating a VB.NET application and I want that application to be able to take ownership of few Registry keys.
There doesn't seem to be an easy way to do this. Someone suggested to me a complex procedure that requires about 300 lines of code. It seems to me that is too much effort for what is conceptually an easy task.
So, is there a straightforward way to change or take ownership of a Registry key?
Upvotes: 1
Views: 499
Reputation: 109100
Assuming the current user has the necessary rights to take ownership:
RegistryKey
instance for the key.GetAccessControl()
to get the ACL.SetOwner
on the ACL passing the necessary user identity.SetAccessControl
to replace the ACL on the registry key.(I suspect the 300 lines of code was using P/Invoke from the days before the .NET framework had support for reading and manipulating ACLs.)
Upvotes: 2