473,395 Members | 1,474 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,395 software developers and data experts.

take ownership of registry key with .NET 2.0?

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, of course is that normally, to read or change permissions, one
needs to "open" the registry key to get a handle to it.. but of course if
you do not have permission to do that, it fails and you get a null handle
which is pretty much useless for changing registry key access ;)

I open a root key:

RegistryKey myKey = Registry.ClassesRoot; // or whichever..

And try to open my sub key, which I only have "write owner" permission
(with "true" for write, since I want to write a new owner):

myKey = myKey.OpenSubKey("mySubKeyName", true);

Which, of course.. fails.

The issue is obviously known to MS, since they have a page specifically on
how to solve the problem in C++ (I think?) at:

http://support.microsoft.com/default...b;en-us;111546

Any help very much appreciated! -- Thanks!

--
Andrew
Nov 17 '05 #1
2 4122

"Andrew" <no******************@earth.universe> wrote in message
news:17*****************************@40tude.net...
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, of course is that normally, to read or change permissions,
one
needs to "open" the registry key to get a handle to it.. but of course if
you do not have permission to do that, it fails and you get a null handle
which is pretty much useless for changing registry key access ;)

I open a root key:

RegistryKey myKey = Registry.ClassesRoot; // or whichever..

And try to open my sub key, which I only have "write owner" permission
(with "true" for write, since I want to write a new owner):

myKey = myKey.OpenSubKey("mySubKeyName", true);

Which, of course.. fails.

The issue is obviously known to MS, since they have a page specifically on
how to solve the problem in C++ (I think?) at:

http://support.microsoft.com/default...b;en-us;111546

Any help very much appreciated! -- Thanks!

--
Andrew


Only "admlinistrators" can do this, are you running as an administrator?.

Willy.
Nov 17 '05 #2
Only "admlinistrators" can do this, are you running as an administrator?.

Willy.


I was under the impression that anybody with "write owner" permission could
do it. Thanks for the tip.

However, I am running windows XP as an administrator.

--
Andrew
Nov 17 '05 #3

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

Similar topics

1
by: Ryan | last post by:
We have a DTS package developed on our development PC's (SQL 7). It runs fine. When we schedule it on the server (SQL 7), it fails. We have been able to find that this is a known issue down to the...
4
by: tarmat | last post by:
I've been using code such as the following, whereby I call the constructor of a class with an object allocated on the heap. The class is responsible for tidying up the memory. class Base{};...
11
by: Jacob | last post by:
I am trying to find the best way of documenting (in code and comments) ownership of secondary contained objects. This is my current status, and I would appreciate feedback on it: Case 1: ...
2
by: Benden Ziyade | last post by:
Hello; I want to write a C program that check file ownership in /bin directory(ls, mkdir...). But I don't know how I start. I'm happy with your helping.
0
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: ShaiH | last post by:
When I create a file from a simple command line application written in C# the file ownership given to the newly created file is of administrators group although I am running this application in my...
3
by: YXQ | last post by:
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...

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.