473,566 Members | 2,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Take ownership of Registry key using vb2005

YXQ
Hello,
I need to programmaticall y take ownership of a registry-key as
current user using VB2005. To test this , i created a key
HKEY_LOCAL_MACH INE\Software\Te stKey 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.Princi pal.NTAccount = New
Security.Princi pal.NTAccount(E nvironment.User DomainName & "\" &
Environment.Use rName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalM achine.OpenSubK ey(subKey,
RegistryKeyPerm issionCheck.Rea dSubTree,
Security.Access Control.Registr yRights.TakeOwn ership)
Dim rs As Security.Access Control.Registr ySecurity =
rk.GetAccessCon trol()
rs.SetOwner(use r)
MessageBox.Show ("done")
Feb 12 '07 #1
3 3023
why in the fuck would you use the registry?

IS UNNECESSARY COMPLEXITY _SEXY_ OR SOMETHING

On Feb 12, 12:15 am, "YXQ" <g...@163.comwr ote:
Hello,
I need to programmaticall y take ownership of a registry-key as
current user using VB2005. To test this , i created a key
HKEY_LOCAL_MACH INE\Software\Te stKey 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.Princi pal.NTAccount = New
Security.Princi pal.NTAccount(E nvironment.User DomainName & "\" &
Environment.Use rName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalM achine.OpenSubK ey(subKey,
RegistryKeyPerm issionCheck.Rea dSubTree,
Security.Access Control.Registr yRights.TakeOwn ership)
Dim rs As Security.Access Control.Registr ySecurity =
rk.GetAccessCon trol()
rs.SetOwner(use r)
MessageBox.Show ("done")

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

Robin S.
------------------
"YXQ" <ga***@163.comw rote in message
news:e5******** ******@TK2MSFTN GP06.phx.gbl...
Hello,
I need to programmaticall y take ownership of a registry-key as
current user using VB2005. To test this , i created a key
HKEY_LOCAL_MACH INE\Software\Te stKey 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.Princi pal.NTAccount = New
Security.Princi pal.NTAccount(E nvironment.User DomainName & "\" &
Environment.Use rName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalM achine.OpenSubK ey(subKey,
RegistryKeyPerm issionCheck.Rea dSubTree,
Security.Access Control.Registr yRights.TakeOwn ership)
Dim rs As Security.Access Control.Registr ySecurity =
rk.GetAccessCon trol()
rs.SetOwner(use r)
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.comwr ote in message

news:e5******** ******@TK2MSFTN GP06.phx.gbl...
Hello,
I need to programmaticall y take ownership of a registry-key as
current user using VB2005. To test this , i created a key
HKEY_LOCAL_MACH INE\Software\Te stKey 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.Princi pal.NTAccount = New
Security.Princi pal.NTAccount(E nvironment.User DomainName & "\" &
Environment.Use rName)
Dim subKey As String = "test"
Dim rk As RegistryKey = Registry.LocalM achine.OpenSubK ey(subKey,
RegistryKeyPerm issionCheck.Rea dSubTree,
Security.Access Control.Registr yRights.TakeOwn ership)
Dim rs As Security.Access Control.Registr ySecurity =
rk.GetAccessCon trol()
rs.SetOwner(use r)
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
4143
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 examples.. I can still find nothing that demonstrates how to take ownership of a Registry key if one has (potentially) *only* "write owner" The problem,...
0
1323
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: http://support.microsoft.com/kb/111546/EN-US/ ...except that I would like to know how to do it in C# Any help would be much appreciated. Thanks!
9
7207
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 2.0 *IF* one has _only_ TakeOwnership privilege? The problem is exactly as specified in MS KB Article ID: 111546 at:...
1
13367
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 a for a few days. I'm trying to read a registry value from a remote system's registry using WMI (System.Management). I'm able to connect to the...
1
1575
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 not allowed." Any idea why?
5
5622
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
2699
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 XML. thanks in advance.
0
831
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
20955
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
7673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5485
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.