Skip navigation

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

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
if exist %TEMP%\ del /q %TEMP%\
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%\
sort %TEMP%\dirperms.log
for /f "Tokens=*" %%i in ('type %TEMP%\dirperms.log') do CACLS "%%i ">>%2
del /q %TEMP%\
del /q %TEMP%\dirperms.log


dirperm c:\users c:\temp\perm.log

dirperm "c:\program files" c:\temp\perm.log /s

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.