2013-12-19 90 views
5

权限,我有以下脚本,它工作正常,但我怎么设置它来保持安全设置和添加额外的“人”安全组...更改所有者和文件夹

...和可以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 

回答

10

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.