Setup permissions and ownership on multiple folders
In many clients I have worked with, there is Folder Redirection setup on the server for the users. While it is extremely useful, it can have issues with permissions when trying to move them to a new server. The user folder may have only system and end user permissions. To overcome this, you’d need to take ownership, reassign permissions and give ownership back.
To make it automated, you can do 3 things. First the script needs to be placed one folder above redirection folder. You can tweak it to run it from anywhere.
Save below file as takeo.cmd
REM Recursively assign ownership to Administrators. Answer prompts with "Y".
takeown /R /A /F "Redirected Folders\%1" /D Y
REM Grant Full permissions on folder and subfolders to Administrators, SYSTEM, and the user
cacls "Redirected Folders\%1" /T /E /P "Administrators":F
cacls "Redirected Folders\%1" /T /E /P SYSTEM:F
cacls "Redirected Folders\%1" /T /E /P %1:F
REM Set owner back to UserName
subinacl.exe /noverbose /subdirectories "Redirected Folders\%1\*.*" /setowner=%1
If you don’t have a copy of subinacl.exe from Windows Resource Kit, you can grab it from Microsoft. Direct link was dead, so I found a copy on archive.org
Next is create a list of folders. Command line is:
Dir /b “E:\redirected folders” > fixo.csv
Change folder to your setup. Then edit fixo.csv and remove folders you don’t need to change.
Next it is time to wrap it with a bow, save following as fixo.cmd:
FOR /F %%A IN (fixo.csv) DO (
As simply put, it goes line by line contents of fixo.csv, then plugs them into takeo.