473,410 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Take ownership of Registry key using vb2005

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/micro...7d20dc77f98e8f

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.UserDomai nName & "\" &
Environment.UserName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey(subKey,
RegistryKeyPermissionCheck.ReadSubTree,
Security.AccessControl.RegistryRights.TakeOwnershi p)
Dim rs As Security.AccessControl.RegistrySecurity =
rk.GetAccessControl()
rs.SetOwner(user)
MessageBox.Show("done")
Feb 12 '07 #1
3 3015
why in the fuck would you use the registry?

IS UNNECESSARY COMPLEXITY _SEXY_ OR SOMETHING

On Feb 12, 12:15 am, "YXQ" <g...@163.comwrote:
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/micro...uage/browse_th...

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.UserDomai nName & "\" &
Environment.UserName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey(subKey,
RegistryKeyPermissionCheck.ReadSubTree,
Security.AccessControl.RegistryRights.TakeOwnershi p)
Dim rs As Security.AccessControl.RegistrySecurity =
rk.GetAccessControl()
rs.SetOwner(user)
MessageBox.Show("done")

Feb 14 '07 #2
Ignore LarryLinson; he's just trolling.

Robin S.
------------------
"YXQ" <ga***@163.comwrote in message
news:e5**************@TK2MSFTNGP06.phx.gbl...
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/micro...7d20dc77f98e8f

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.UserDomai nName & "\" &
Environment.UserName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey(subKey,
RegistryKeyPermissionCheck.ReadSubTree,
Security.AccessControl.RegistryRights.TakeOwnershi p)
Dim rs As Security.AccessControl.RegistrySecurity =
rk.GetAccessControl()
rs.SetOwner(user)
MessageBox.Show("done")


Feb 14 '07 #3
it is true.

99% of developers should -NEVER- touch the registry


On Feb 14, 12:37 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Ignore LarryLinson; he's just trolling.

Robin S.
------------------"YXQ" <g...@163.comwrote in message

news:e5**************@TK2MSFTNGP06.phx.gbl...
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/micro...uage/browse_th...
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.UserDomai nName & "\" &
Environment.UserName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey(subKey,
RegistryKeyPermissionCheck.ReadSubTree,
Security.AccessControl.RegistryRights.TakeOwnershi p)
Dim rs As Security.AccessControl.RegistrySecurity =
rk.GetAccessControl()
rs.SetOwner(user)
MessageBox.Show("done")- Hide quoted text -

- Show quoted text -

Feb 14 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andrew | last post by:
I spent tons of time searching the web for how to use .NET 2.0 and C# to modify Registry key security. After finally finding an example, and once I knew the function names a few other small...
0
by: Andrew | last post by:
How does one go about taking ownership of a registry key using C# & .NET 2.0 *IF* one has _only_ TakeOwnership privilege? The problem is exactly as specified in MS KB Article ID: 111546 at:...
9
by: Andrew | last post by:
Apologies for the double-post.. I'm new, just getting used to this.. and should have posted this way in the first place.. How does one go about taking ownership of a registry key using C# & .NET...
1
by: JJG | last post by:
Hello. I'm not sure if this is the right forum, so please let me know what is the correct one if it isn't. (I posted this one also to the win32.programmer.wmi forum). I've been puzzled by this...
1
by: Nikolay Petrov | last post by:
I cannot write to windows registry using ASP .NET account. I have made a key in HKEY_LOCAL_MACHINE\Software and granted full access to ASP .NET account, but still got "Requested registry access is...
5
by: Mazharrana | last post by:
hi I want to access registry using java, I want to find list of hardware or software installed in my PC using java programe. How can i do this? If any one know ? Please help me. Regards Mazhar
1
by: kbnumesh | last post by:
Dear All, I have query regarding the registry. Is it possible to write it to windows registry using the XML? if yes then what is the API or tag used to write it. I am just a beginner in...
0
by: Camille2007 | last post by:
Hello, I would like to know how to print pages/sheet in zoom option in print dialog box using vb2005? Any help would be very appreciated.
5
by: nilaangel78 | last post by:
Hi All, I want read the below remote registry using VB.Net. "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products" Please anyone help me. Thanks
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.