Click here to Skip to main content
13,298,731 members (47,645 online)
Click here to Skip to main content
Add your own
alternative version


17 bookmarked
Posted 20 Sep 2005

VBScript Recursive ACL List

, 20 Sep 2005
Rate this:
Please Sign up or sign in to vote.
List a directory and its subdirectories' access control list.

Quick and easy ACL printout

This is a VBScript which will list the ACL for all subdirectories in the directory you specify. Many businesses like to have a paper record of security settings for disaster recovery but no built in tool in Windows will print the ACLs of multiple directories at a time and the alternatives like "pracl" are fairly expensive.

It's quite a pain with anything but the most simple directory structure to manually print them so I took the "VBScript directory crawler" and modified it to launch cacls to display the ACL information for the directory and all subdirectories.

Obviously, to put this output into a file you just execute "cscript listacl.vbs > acl.txt".

The code

'    ListACL.vbs
'    ACL Modifications by CyberneticWraith, 2005
'    Changed it to display ACL information for folders
'    Uses "cacls.exe"
'    Run with cscript!
'    IndexScripts()
'    Written by Keep Bertha Surfin Heavy Industries,
'    a division of Keep Bertha Surfin Electrical Concern
'    Version 1.0 -

' First thing, check the argument list for a directory.
' If they didn't specify one, use the current directory.

option explicit

' Run the function :)
call IndexScripts

sub IndexScripts()

    dim fso
    set fso = createobject("scripting.filesystemobject")

    dim loc
    if WScript.Arguments.Count = 0 then
        loc = fso.GetAbsolutePathName(".")
        loc = WScript.Arguments(0)
    end if

    GetWorkingFolder loc, 0, 1, "|"

    set fso = nothing
End Sub

' called recursively to get a folder to work in
function GetWorkingFolder(foldspec, foldcount, _
                                   firsttime, spacer)

    Dim objShell,oExec
    Set objShell = CreateObject("WScript.Shell")
    dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")

    dim fold
    set fold = fso.GetFolder(foldspec)
    dim foldcol
    set foldcol = fold.SubFolders
    'do the first folder stuff
    if firsttime = 1 then
        wscript.echo fold.path
        foldcount = foldcol.count
        firsttime = 0
    end if
    dim remaincount
    remaincount = foldcol.count
    'do the subfolder stuff
    dim sf
    for each sf in foldcol
        'execute cacls to display ACL information
        Set oExec = _
          objShell.Exec("cacls " & chr(34) & sf.path & chr(34))
        Do While Not oExec.StdOut.AtEndOfStream
             str = oExec.StdOut.ReadAll
             Dim str
             Wscript.StdOut.WriteLine str
        set oExec = nothing
        remaincount = GetWorkingFolder (foldspec +"\", _
                                   remaincount, firsttime, spacer)
    'clean up
    set fso = nothing
    GetWorkingFolder = foldcount - 1

end function


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

Generalone more better way. Pin
anand choubey9-Apr-09 11:39
memberanand choubey9-Apr-09 11:39 
GeneralSystem Volume Information Pin
SamKost30-Apr-08 12:02
memberSamKost30-Apr-08 12:02 
Generalvb script: open a folder & list its files Pin
hitthelink21-Mar-07 3:28
memberhitthelink21-Mar-07 3:28 
QuestionACL list of Registry Keys Pin
GTS202016-Oct-06 3:06
memberGTS202016-Oct-06 3:06 
GeneralBy User Pin
Fluid Dynamics Software3-Mar-06 5:21
memberFluid Dynamics Software3-Mar-06 5:21 

It'd be nice to be able to specify a particular user account that you're interested in. I started to modify the script but I'm not familiar enought with VBS, particilarly the "objShell.Exec("cacls " & chr(34) & sf.path & chr(34))" line which is where the work seems to be done.

Nice tool though, thanks for sharing.
GeneralRe: By User Pin
cyberneticwraith3-Mar-06 6:06
membercyberneticwraith3-Mar-06 6:06 
Questiongetting Error Pin
Anonymous28-Sep-05 3:49
sussAnonymous28-Sep-05 3:49 
AnswerRe: getting Error Pin
cyberneticwraith5-Oct-05 6:50
membercyberneticwraith5-Oct-05 6:50 
AnswerRe: getting Error Pin
Michael Weyant30-Oct-05 21:51
memberMichael Weyant30-Oct-05 21:51 
GeneralNice... Pin
jalbitz27-Sep-05 4:42
memberjalbitz27-Sep-05 4:42 
GeneralRe: Nice... Pin
cyberneticwraith27-Sep-05 8:55
membercyberneticwraith27-Sep-05 8:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 20 Sep 2005
Article Copyright 2005 by cyberneticwraith
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid