473,805 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 .SecurityExcept ion: Requested registry access is not allowed

// ----start----
SetPermissions( ){
String^ user = Environment::Us erDomainName + "\\testuser ";
RegistryKey^ openedKey;
RegistrySecurit y regSecurity = gcnew RegistrySecurit y();
regSecurity->AddAccessRule( gcnew RegistryAccessR ule(user,
RegistryRights: :ReadKey,
InheritanceFlag s::ContainerInh erit | InheritanceFlag s::ObjectInheri t,
PropagationFlag s::InheritOnly,
AccessControlTy pe::Allow));
regSecurity->SetAccessRuleP rotection(false ,true);
openedKey =
Registry::Users->OpenSubKey(" S-1-5-18\\software\\t estkey",true);
openedKey->SetAccessContr ol(regSecurity) ;
return 0;
}
// ----end----
Oct 20 '07 #1
1 2277
"Judith Schmidt" <an*********@ao l.comwrote in message
news:Ok******** ******@TK2MSFTN GP06.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 .SecurityExcept ion: Requested registry access is not
allowed

// ----start----
SetPermissions( ){
String^ user = Environment::Us erDomainName + "\\testuser ";
RegistryKey^ openedKey;
RegistrySecurit y regSecurity = gcnew RegistrySecurit y();
regSecurity->AddAccessRule( gcnew RegistryAccessR ule(user,
RegistryRights: :ReadKey,
InheritanceFlag s::ContainerInh erit | InheritanceFlag s::ObjectInheri t,
PropagationFlag s::InheritOnly,
AccessControlTy pe::Allow));
regSecurity->SetAccessRuleP rotection(false ,true);
openedKey =
Registry::Users->OpenSubKey(" S-1-5-18\\software\\t estkey",true);
openedKey->SetAccessContr ol(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
3938
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 (Default) a Dword using the CreateSubKey method? If not, How can I use the SetValue Method t change the Default from RG_SZ to DWord?
7
14836
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 logged in as an Administrator and it's a Windows app. What permission does it need? Here's the code. private void ChangeReg() { string regPath = "SOFTWARE\\Microsoft\\.NETFramework\\AssemblyFolders"; RegistryKey thisKey = Registry.LocalMachine;
0
3274
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 NT\CurrentVersion\HotFix but I get a permissions error when I try to access HKLM\Software\Network Associates\TVD\Shared Components\VirusScan Engine\4.0.xx. The security permissions are identical on these two keys. Here is my code: RegistryKey...
1
3385
by: Brian Keating | last post by:
Hi there anyone know to the get the native registry Handle from a RegistryKey? thanks in advance
1
2190
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 IsScreenSaverSecure = 1 (something like that)) If you have any thoughts or ideas on this please let me know. I can login as Administrator but with this setting protected but it is not allowing a reboot to occur if the screensaver is on and password protected....
2
12704
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 it to not require a password prompt anymore. One change that would be helpful is to somehow figure out how to include an IP address where the server name is called. I suspect it is a syntax I am missing. This morning I was running it from...
4
3234
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
1843
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
31232
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, new_value_string); I am getting error: System.UnauthorizedAccessException: Cannot write to the registry key.
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10617
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10364
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5545
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4328
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.