JSI Tip 0596 - How do I print the permissions on a directory tree?

Jerold Schulman

July 8, 1998

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like