@echo off IF %1.==. GOTO USAGE if /I %1 == %SystemDrive% goto nosystemdrive if /I %1 == %SystemDrive%\ goto nosystemdrive if NOT EXIST %1 ( echo ERROR: file or directory not found! exit /b ) echo setting permissions for Users on [ %1 ] to FULL-ACCESS ... if EXIST %1\* ( echo *** DIRECTORY mode *** takeown /F %1 /R /A /D Y 1>nul icacls %1 /inheritance:r icacls %1 /grant Administrators:F /t /c /l /q icacls %1 /grant Users:F /t /c /l /q ) else ( echo *** FILE mode *** takeown /F %1 /A 1>nul icacls %1 /inheritance:r icacls %1 /grant Administrators:F /c /l /q icacls %1 /grant Users:F /c /l /q ) echo. icacls %1 GOTO END :nosystemdrive echo ERROR: cannot use the SystemDrive! GOTO END :USAGE echo "usage: %0 " :END