Changing permissions in a BAT file
- I need to delete these files:
I'm getting an error: Access is denied
I've tried running it a administrator It gives the same error.
I have found a script that will set the permissions so I can delete the files:
for /f "tokens=*" %%a in ('dir /ad /b ^"%USERDIRS%^"') do (
takeown /R /A /F "%USERDIRS%\%%a" /D Y
xcacls "%USERDIRS%\%%a" /T /E /P Administrators:F
xcacls "%USERDIRS%\%%a" /T /E /P SYSTEM:F
xcacls "%USERDIRS%\%%a" /T /E /P %%a:F
subinacl.exe /noverbose /file "%USERDIRS%\%%a" /setowner=%%a
subinacl.exe /noverbose /subdirectories "%USERDIRS%\%%a\*"
I'm not familiar enough with the commands to know if this script will work for the files
I need deleted and only the files I need deleted. I have not tested the script.
Could someone that knows these commands please make sure this script will affect the
files I am working with and not other files on the system.