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

Pav*_*vic 5 vbscript command-line 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
Run Code Online (Sandbox Code Playgroud)

Job*_*bbo 12

CACLS不推荐使用,您可以通过推荐实现您想要的效果ICACLS.你想要的东西:

icacls.exe d:\test /grant domain\username:F
Run Code Online (Sandbox Code Playgroud)

要添加权限,请执行以下操作:

icacls.exe d:\test /setowner domain\username
Run Code Online (Sandbox Code Playgroud)

设置所有权.其他感兴趣的选项来自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.
Run Code Online (Sandbox Code Playgroud)