SetACL - http://setacl.sourceforge.net/
SetACL is a set of routines for managing Windows permissions (ACLs) from the command line, from scripts and from programs.
Here is a function / macro that can be used to delete stubborn registry keys (like those left behind after driver uninstallations in the HKLM\SYSTEM\CurrentControlSet\Enum\Root\LEGACYxxx keys). At least a few people might find this useful.
AutoIt -
$setacl = '"X:\path\to\SetACL.exe"' Func _SetACL_DeleteKey($key) ; check if key exists RegRead($key, "") If @error 0 And @error -1 Then SetError(@error) Else ; set owner / permissions and delete key RunWait($setacl & ' -on "' & $key & '" -ot reg -rec yes ' & _ '-actn clear -clr "dacl" ' & _ '-actn setowner -ownr "n:Administrators" ' & _ '-actn ace -ace "n:Everyone;p:full"' _ , "", @SW_HIDE) RegDelete($key) EndIf EndFunc
NSIS -
(requires Registry plugin)
!include Registry.nsh Var setacl !define SetACL_DeleteKey "!insertmacro _SetACL_DeleteKey" !macro _SetACL_DeleteKey key Push $0 ; check if key exists ${registry::KeyExists} "${key}" $0 StrCmp $0 0 0 End ; set owner / permissions and delete key ExecWait '"$setacl" -on "${key}" -ot reg -rec yes \ -actn clear -clr "dacl" \ -actn setowner -ownr "n:Administrators" \ -actn ace -ace "n:Everyone;p:full"' ${registry::DeleteKey} "${key}" $0 End: Pop $0 !macroend Section StrCpy $setacl "X:\path\to\SetACL.exe" ${SetACL_DeleteKey} "key\to\delete" SectionEnd
hey.. i tried this with NSIS but it doesn't seem to work for me.
i copied:
Saved into NSIS's 'Include' directory as 'SetACL_DeleteKey.nsh'.
and in my script i have:
setcacl.exe is in the bin directory of NSIS of course.
Can you tell me where im going wrong?
everything compiles, runs, and terminates..
but the key is not being deleted?
Thanks
F.Y.I
i have also tried AccessControl plugin without success.
I can't seem to delete this key in Windows 7.
I found a program that is able to that grants 'System' rights..
but i can't seem to figure that out with AccessControl .