batch file comman
we have a set of user home folders that have been migrated from our old domain to our new domain and they have broken ACLs. I know how to use cacls commands but the %username% parameter needs to match the foldername. how do I parse the folder name and use it as the username to match the user to the folder?
racking brains and brains failing!!:tinfoil3:
Well you could script it (i have one at work i can provide) or you could use the free NTFSFix
WiseSoft - NTFSFix. NTFS Permissions Utility.
I found this VB script, but I havn't personally tested it, so use it with caution. It seems to do what you want, as long as the username is exactly the same as the folder name you're changing.
You can change the CACLS command line to totally replace the ACL if your ACLs are totally broken, follow the help attached to the CACLS program to find out what switches you need to change. You will also need to add in the other users you want to have access e.g adminstrator to the end of the CACLS line if you do this. Running it in its current form edits the ACL and adds in the necessary permissions for the matching user only.
If running it on the server, which I would recommend you do, and not from a workstation across the network, change from using the UNC path to the local path insted.
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPath = "\\Server\HomefolerPath" '<--- Homefolder UNC path
Set objFolder = objFSO.GetFolder(strPath)
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
strFolderName = objSubFolder.Name
Set objShell = CreateObject("Wscript.Shell")
strExec = objShell.Run("%COMSPEC% /c Echo Y| cacls " _
& strFolderName & " /E /T /P " & strFolderName & ":F ", 2, True) '<--- 1st "strFolderName" reflects the homefolder name. 2nd "strFolderName" reflects Username
If strExec <> 0 Then
MsgBox "Error with " & strFolderName & " and folder: " & strFolderName
hope that's of help.
I was just about to suggest this and realised you had already - anyway just wanted to add a side note and mention that registration is free and then you can get to the downloads ( which are obviously free as well ) afaik ( at least they were last time I checked )
Originally Posted by cookie_monster
very handy utils on that site as well ( password changer, ntfs fixer ) and possibly some other ones.