473,395 Members | 1,668 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.

How could i change permission on registrykey

Hi

i need a way to set permission on a registry key where i have got not rights
to open it. But i am the owner (administrator).

The following code fails on OpenSubKey() with
System.Security.SecurityException: Requested registry access is not allowed

// ----start----
SetPermissions(){
String^ user = Environment::UserDomainName + "\\testuser";
RegistryKey^ openedKey;
RegistrySecurity regSecurity = gcnew RegistrySecurity();
regSecurity->AddAccessRule(gcnew RegistryAccessRule(user,
RegistryRights::ReadKey,
InheritanceFlags::ContainerInherit | InheritanceFlags::ObjectInherit,
PropagationFlags::InheritOnly,
AccessControlType::Allow));
regSecurity->SetAccessRuleProtection(false,true);
openedKey =
Registry::Users->OpenSubKey("S-1-5-18\\software\\testkey",true);
openedKey->SetAccessControl(regSecurity);
return 0;
}
// ----end----
Oct 20 '07 #1
1 2264
"Judith Schmidt" <an*********@aol.comwrote in message
news:Ok**************@TK2MSFTNGP06.phx.gbl...
Hi

i need a way to set permission on a registry key where i have got not
rights to open it. But i am the owner (administrator).

The following code fails on OpenSubKey() with
System.Security.SecurityException: Requested registry access is not
allowed

// ----start----
SetPermissions(){
String^ user = Environment::UserDomainName + "\\testuser";
RegistryKey^ openedKey;
RegistrySecurity regSecurity = gcnew RegistrySecurity();
regSecurity->AddAccessRule(gcnew RegistryAccessRule(user,
RegistryRights::ReadKey,
InheritanceFlags::ContainerInherit | InheritanceFlags::ObjectInherit,
PropagationFlags::InheritOnly,
AccessControlType::Allow));
regSecurity->SetAccessRuleProtection(false,true);
openedKey =
Registry::Users->OpenSubKey("S-1-5-18\\software\\testkey",true);
openedKey->SetAccessControl(regSecurity);
return 0;
}
// ----end----


That means you don't run as "administrator". Be aware that "administrators"
run as normal users on Vista! If you need to perform administrative tasks
you'll have to run with elevated privileges.

Willy.

Oct 20 '07 #2

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

Similar topics

6
by: Yogi_Bear_79 | last post by:
I'm Creating new Keys in the registry, but when I do, they always have a Vaule called (Default) type RG_SZ. I need them to be DWord dword:00000005 Is there a way to automaticaly make the...
7
by: Bob | last post by:
I'm working on a Windows app that needs to write to the Registry HKLM. I keep getting a "System.UnauthorizedAccessException: Cannot write to the registry key." error when running the app. I'm...
0
by: g82martin | last post by:
I am using the RegistryKey class to access the registry on remote machines. I only require read access. I am able to successfully read registry keys under HKLM\Software\Microsoft\Windows...
1
by: Brian Keating | last post by:
Hi there anyone know to the get the native registry Handle from a RegistryKey? thanks in advance
1
by: scorpion53061 | last post by:
Trying to change a value named in a remote registry. In this case we want to set the password protect function of the screensaver so WMI can do a reboot of the system. (IsSecure or...
2
by: scorpion53061 | last post by:
hi all, I thought I would give this back and see if anyone could improve on it. I was working with the remote registry class. This code opens the ScreenSaverIsSecure registry setting and changes...
4
by: yxq | last post by:
Hello, I want to get the registry key permission information whether current user has the permission to delete the registry key using RegistryRights, how to do? thank you.
5
by: YXQ | last post by:
How to detect programmatically if current user has the deleting permission to delete a Registry key in VS 2005? thank you very much!
4
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I have Visual Studio 2005 Express Edition. I am trying to change registry value by: RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\My_app"); key.SetValue(name_of_value,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: 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:
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
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
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.