To "print" the permissions on a directory tree:
dirperm "<Drive:>\Folder" "<Drive:>\Directory\Output.txt" \[/S\] were:
"<Drive:>\Folder" is the directory whose tree you wish to enumerate.
"<Drive:>\Directory\Output.txt" is the full path to the output file.
/S will get all sub-directories, not just the 1st level.
dirperm.bat should be in your path and contains:
@echo off
if exist %2 del /q %2
if /i "%3"=="/s" goto sub
CACLS %1 >>%2
CACLS %1\*.* >>%2
exit
:sub
if exist %TEMP%\DirPerms.srt del /q %TEMP%\DirPerms.srt
if exist %TEMP%\DirPerms.log del /q %TEMP%\DirPerms.log
CACLS %1 >>%2
for /f "Tokens=*" %%i in ('dir %1\*.* /B /AD /ON /S') do echo %%i>>%TEMP%\DirPerms.srt
sort %TEMP%\dirperms.log
for /f "Tokens=*" %%i in ('type %TEMP%\dirperms.log') do CACLS "%%i ">>%2
del /q %TEMP%\dirperms.srt
del /q %TEMP%\dirperms.log
exit
Examples:
dirperm c:\users c:\temp\perm.log
dirperm "c:\program files" c:\temp\perm.log /s