更改文件夹的所有者和权限

时间:2013-12-19 04:40:30

标签: command-line vbscript cacls

我有以下脚本,它工作正常,但我如何设置它以保持安全设置并向安全组添加额外的“人”......

...并且cacls可以更改文件夹的“所有者”吗?

我累了/e来编辑而不是替换,但由于某些原因它不喜欢它?

Set WshShell = CreateObject("WScript.Shell")
strFolder    = "D:\test"

setPerms     = "%COMSPEC% /c echo Y| C:\windows\system32\cacls.exe """ & _
                strFolder & """ /G mydomain\myusername:F & pause" 'added pause to see what the outcome is

WshShell.run setPerms

1 个答案:

答案 0 :(得分:12)

不推荐使用

CACLS,您可以使用推荐的ICACLS达到您想要的效果。你想要这样的东西:

icacls.exe d:\test /grant domain\username:F

添加权限并添加:

icacls.exe d:\test /setowner domain\username

设置所有权。其他感兴趣的选项来自icacls /?

/T indicates that this operation is performed on all matching
    files/directories below the directories specified in the name.

/C indicates that this operation will continue on all file errors.
    Error messages will still be displayed.