473,397 Members | 2,033 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,397 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 4123

"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: 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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.