本帖最后由 9zhmke 于 2016-1-18 11:24 编辑
以前一直使用SetAcl来做自己的优化程序,前几天安装了个锋城的精简版Win10,发现用之前的SetAcl语句无法正常使用了,有没有直接使用VBS语句对注册表取得所有权,然后能重置某个子树权限的方法呢?
附上以前使用的程序片段:- SetRegACL("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}")
- WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\"
-
- Function SetRegACL(reg_path) '为当前用户设置注册表权限
- dim tmp1,tmp2,tmp3,sid
- Set tmp1 = Getobject("winmgmts:\\.") '取当前用户SID
- Set tmp3=tmp1.execquery("select sid from win32_userAccount where name='"&WshShell.ExpandEnvironmentStrings("%username%") &"'")
- For Each tmp2 In tmp3
- sid = tmp2.sid
- Next
- set tmp1=nothing
- set tmp3=nothing
- tmp1=chr(34) & reg_path & chr(34) & " -ot reg -actn setowner -ownr " & chr(34) & "n:" & sid & ";s:y" & chr(34)
- tmp2=chr(34) & reg_path & chr(34) & " -ot reg -actn ace -ace " & chr(34) & "n:"
- WshShell.Run chr(34) & my_dir & "data\setacl.exe" & chr(34) & " -on " & tmp1,0,true '先获得所有权
- WshShell.Run chr(34) & my_dir & "data\setacl.exe" & chr(34) & " -on " & tmp2 & WshShell.ExpandEnvironmentStrings("%username%") & ";p:full",0,true '再设置用户权限
- End Function
复制代码 完整程序请移步:http://bbs.dp168.com/thread-90732-1-1.html |