Take ownership of Registry key using vb2005

Y

YXQ

Hello,
I need to programmatically take ownership of a registry-key as
current user using VB2005. To test this , i created a key
HKEY_LOCAL_MACHINE\Software\TestKey and removed all accessrights from this
key using RegEdt32.

Now i tried to set the accessrights by my programm. Since i do not have
rights to this key, i cannot open the key to get a handle for modifying the
rights.

http://groups.google.com/group/micr...4340f5c2930/667d20dc77f98e8f#667d20dc77f98e8f



I use the code below to take ownership, but it will not work.
Could anyone tell how to modify it? Thank you very much.

////////////////////////////////////////////////
Dim user As Security.Principal.NTAccount = New
Security.Principal.NTAccount(Environment.UserDomainName & "\" &
Environment.UserName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey(subKey,
RegistryKeyPermissionCheck.ReadSubTree,
Security.AccessControl.RegistryRights.TakeOwnership)
Dim rs As Security.AccessControl.RegistrySecurity =
rk.GetAccessControl()
rs.SetOwner(user)
MessageBox.Show("done")
 
L

Larry Linson

why in the **** would you use the registry?

IS UNNECESSARY COMPLEXITY _SEXY_ OR SOMETHING
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top