computing
  • 6

Batch Script To List Folder Permissions

  • 6

Hi,

I would like to write a batch script to perform the following tasks,

1) The script should ask the user to input the drive information (C:\, D:\, etc)
2) Once the user inputs the drive information, it should print all the folders (not sub-folders, only the folders) in that drive to a file.
3) Now the script should find the folder permissions for the list of folders printed in the file.
4) It should print the output to a file.

I’ve the script to do the steps 3 & 4. But currently it will work only on the folder you specify. I want to have this done for all the folders in a drive.

@echo off
set target=C:\test
cacls “%target%” > c:\list.txt
for /F “tokens=*” %%* in (‘dir /b /ad “%Target%”‘) do cacls “%target%%%*”

Share

1 Answer

  1. @echo off & setlocal
    set /P target=Enter Drive letter (e.g. C:)^>
    type nul > C:\list1.txt
    cd /D %target%\
    for /F "delims=" %%j in ('dir /B /AD') do echo.%%~fj >> C:\list1.txt
    type nul > C:\list2.txt
    for /F "delims=" %%j in (C:\list1.txt) do echo.%%j %%~aj >> C:\list2.txt
    type C:\list2.txt
    :: End_Of_Batch
    

    • 0