开发者

VBScript / PowerShell , how to write a script to secure Windows Registry

I wanted to use WScript.Shell object to secure a registry pa开发者_JAVA技巧th , e.g HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Registration\UserProfile.

So the objective is that , create a new permission for 'everyone' , and deny the following: Delete , Create SubKeys etc.

Googled a lot , and didn't get a deal on my specific problem , could anyone give me a hint on this point ? Thanks !


maybe this can help

$acl = Get-Acl "HKLM:\SOFTWARE\Business Objects\Registration\UserProfile"
$rule = New-Object System.Security.AccessControl.RegistryAccessRule ("mycomp\everyone","FullControl","Allow") # or deny...
$acl.SetAccessRule($rule)
$acl |Set-Acl -Path "HKLM:\SOFTWARE\Business Objects\Registration\UserProfile"

To add or remove an access rule you need to create the rule as an object of type RegistryAccessRule, and then either create or remove the rule from the ACL with the SetAccessRule() or RemoveAccessRule() methods

Just for have another example: Set-ACL on registry key

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜