2013-12-19 145 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.