Fix permissions on user .v2 profiles folders

Fix permissions on user share or profiles folders

The following script is similar to a script that I created back in Windows 2000 server days.  I have misplaced that script (probably still being used at the last place I worked).  I did a search and found a better version of my script by leaps and bounds.  The following was copied URL: http://wiki.mundy.co/Fix_permissions_on_user_share_or_profiles_folders

This script fixes the permissions of a single user profile folder. Save the following script as fixpermissions.bat in the base of your profiles directory:

REM get the username
set tempuser=%1
set username=%tempuser:.v2=%
REM Recursively assign ownership to Administrators.  Answer prompts with "Y". 
takeown /R /A /F %1 /D Y 
REM Grant Full permissions on folder and subfolders to Administrators, SYSTEM, and the user 
cacls %1 /T /E /P "Administrators":F 
cacls %1 /T /E /P SYSTEM:F 
cacls %1 /T /E /P %username%:F 
REM Set owner back to UserName 
rem subinacl.exe /noverbose /subdirectories %1\*.* /setowner=%username%

Run it from the base profiles directory. e.g. if the profile is in E:\Profiles\DanMundy then do the following commands:

e:
cd Profiles
fixpermissions.bat DanMundy

Instead of having to do it manually for each user, you can use the following script to fix the permissions for all users profiles folder. Save the following script as fixall.bat in the same directory as the fixpermissions.bat script:

for /f "delims=" %%i in ('dir /ad/b') do fixpermissions.bat %%i

Run it from the base profiles directory like this:

e:
cd Profiles
fixall.bat
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s