Wednesday, September 19, 2012 9:07 PM
Hi. I'm trying to add a key to the registry and I can't seem to get past the security. What am I doing wrong here? Am I missing something? Here is the code that I am using:
rKey = Registry.LocalMachine.OpenSubKey ("\\SOFTWARE\\Wow6432Node\\Alpha\\DB");
if (rKey == null)
string szUser = Environment.UserDomainName + "\\" + Environment.UserName;
RegistrySecurity rSec = new RegistrySecurity();
RegistryRights.ReadKey | RegistryRights.WriteKey,
rKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Wow6432Node\\Alpha\\DB",
Thanks for looking
- Edited by bmkiss67 Wednesday, September 19, 2012 9:08 PM
Wednesday, September 19, 2012 11:58 PM
May be the problem is related to registry redirection and reflection(happens on 64 bit OS)
please check-out below links
SQL Server Setup Team
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you.
This can be beneficial to other community members reading the thread.
Friday, September 21, 2012 4:35 PMThanks for your reply, but I don't think that redirection or reflection has anything to do with this issue. I don't understand why that could isn't do what I expected it to do.
Friday, September 21, 2012 7:19 PM
Could you check whether you have the required permissions - "ReadPermissions | ChangePermissions | TakeOwnership" - on the registry key path you wish to add the ACLs? (TakeOwnership may not be required though).
As you are creating subkey for the same node, don't you need the CreateSubkey permission too?
Side-note: It is a preferred way to validate your code first with a temporary testing RegistryKey path where you have FullControl and Ownership. After you confirmed the correctness of code, you can proceed with the production code on the required path with required rights.
Sorry-note: You might know these information already because you have used RegistryRights in your code properly. Sorry if I have repeated what you know already.
- Edited by Rajesh_Kannan Friday, September 21, 2012 7:31 PM
Saturday, September 22, 2012 3:34 AMAre you running VS as Admin ??
Digital Forensic Software Developer
CCS LABS Digital Forensic Software
Mark as Answer or Vote up if useful thank you!
Saturday, September 22, 2012 4:41 AM
Microsoft.Win32.RegistryKey key1 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE");
Microsoft.Win32.RegistryKey key2 = key1.OpenSubKey(@"ADM");
Thanks & Regards
Thanks & Regards NVM Prasad * email@example.com Skype ID: prasad.nvm
Monday, September 24, 2012 1:59 PM
Thanks for everyones replies.
Yes, I am running VS as admin.
But one of the other programmers has just changed an aspect of this by giving everyone permission on that set of keys that I was working on. It would seem that I no longer need to worry about the permissions issues I was having. I also found, after doing a lot of searching, a different way of opening the keys that seems to work much better, as least for me. It goes like this:
localMachine = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
rKey = localMachine.OpenSubKey(@"SOFTWARE\Alpha\DB");
That view oprion seems to make things flow better for me.
Anyway, thanks for everyone's help. Hopefully they don't change the permission idea around again.