Skip navigation

JSI Tip 9640. How do I print permissions on a folder tree using standard commands?


In tip 0425, I explained how to read the permissions displayed by the CACLS command.

I have scripted ListPerm.bat, to display the permissions of a folder tree. The syntax for using ListPerm.bat is:

ListPerm "Drive:\Folder" "ReportFile".

Where:

"Drive:\Folder" is the path to the folder you wish to enumerate.

"ReportFile"    is the fully qualified file name of the file that will contain the report.
ListPerm.bat contains:
@echo off
setlocal
IF \{%1\}

\{\} GOTO bad IF NOT EXIST %1 GOTO bad IF \{%2\}

\{\} goto bad set pf=%1 set report=%2 if exist %report% del /q %report% cacls %pf%>%report% for /f "Tokens=*" %%a in ('dir /a /b /ad /s %pf%') do ( cacls "%%a">>%report% ) endlocal GOTO :EOF :bad @echo Usage: ListPerm "Drive:\Folder" "ReportFile" @echo. endlocal



Hide comments

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.
Publish