Monday, July 23, 2012

for /d %i in (*) do @cacls


To CACL the home directories to the existing owners

if you just moved the folders from say NetWare to Windows or a NAS that did not support the permissions (and the user names and home folder names match). This can be used on in the home drive folder (remember to use %% in batch files).

for /d %i in (*) do @cacls ".\%i" /t /e /c /g "domainName\%i":f

for /d %i in (*) do @cacls ".\%i" /t /e /c /g "domainName\Desktop Support":f

for /d %i in (*) do @cacls ".\%i" /t /e /c /g "domainName\Domain Admins":f



Via VBS – if you are adverse to DOS

' THIS must be run from the CURRENT home root DIR

dim DirName, skip

Set WshShell = WScript.CreateObject("WScript.Shell")

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(".\")

Set colSubfolders = objFolder.Subfolders

For Each objSubfolder in colSubfolders

'Wscript.Echo objSubfolder.Name, objSubfolder.Size

DirName = objSubfolder.Name

'Wscript.Echo objSubfolder.Name

'wscript.echo "cmd /c cacls " & objSubfolder.Name & " /t /e /c /g

domainName\" & objSubfolder.Name &":f"

command = "cmd /c cacls " & objSubfolder.Name & " /t /e /c /g

domainName\" & objSubfolder.Name &":f"

Return = WshShell.Run(command, 1, TRUE)



I use this all the time !

No comments:

Blog Archive