Page 1 of 1

How to change registry key acl

Posted: Wed Jan 02, 2013 6:43 pm
by ch1c4um
I need permission to change a registry key for the user Everyone has Full Control access and this way I can delete this key.

I'm using this example

Code: Select all

with RegistrySecurity(HKLM\SYSTEM\ControlSet001\Enum\Root\LEGACY_DMLOAD) do
  begin
    ProtectedDAcl := false;

    DAcl.SetFileAccess(Everyone, True);
    if DAcl.DeleteItems(Everyone) then
      ShowMessage('OK')
    else
      ShowMessage('NOT OK');
  end;
But only modifying this permission and not deleting my key..

I'll use some to clean some keys after uninstall my program

Re: How to change registry key acl

Posted: Wed Jan 09, 2013 6:07 pm
by madshi
Hello,

I'm a bit confused. Your code first adds access for Everyone and then removes it again. Is that intentional? What purpose does that have?

Anyway, the code you're using should more or less work, as long as you have enough privileges to change the ACL. You may have to take ownership first if all else fails. One thing: I'm not sure right now which exact syntax you have to use when feeding a registry path into "RegistrySecurity". It might be safer to call RegOpen/CreateKeyEx() yourself and feed the resulting HKEY into RegistrySecurity.

Re: How to change registry key acl

Posted: Wed Jan 09, 2013 10:29 pm
by ch1c4um
Good night my friend, the above code that i posted by mistake the wrong part
if DAcl.DeleteItems (Everyone) disregard the stretch.

I've got to do what i needed, i was only allowed to change and then run the function to remove key TRegistry, and windows XP I had to work with manipulating tokens to work

Re: How to change registry key acl

Posted: Thu Jan 10, 2013 6:52 am
by madshi
So everything is working fine now?

Re: How to change registry key acl

Posted: Thu Jan 10, 2013 11:02 pm
by ch1c4um
okay my friend, thanks for the feedback