JSI Tip 0596 - How do I print the permissions on a directory tree?
July 8, 1998
To "print" the permissions on a directory tree:
dirperm "Folder" "DirectoryOutput.txt" [/S] were:
"Folder" is the directory whose tree you wish to enumerate.
"DirectoryOutput.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:tempperm.log
dirperm "c:program files" c:tempperm.log /s
About the Author
You May Also Like