Click here to Skip to main content
6,628,952 members and growing! (19,622 online)
Email Password   helpLost your password?
Languages » VBScript » General     Intermediate

VBScript Recursive ACL List

By cyberneticwraith

List a directory and its subdirectories' access control list.
VBScript, Windows, Visual Studio, Dev
Posted:20 Sep 2005
Views:56,479
Bookmarked:11 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
5 votes for this article.
Popularity: 3.03 Rating: 4.33 out of 5

1

2

3
4 votes, 80.0%
4
1 vote, 20.0%
5

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 - KeepBerthaSurfin@Hotmail.com

'


' 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(".")
    else
        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
        Loop
        
        set oExec = nothing
        
        remaincount = GetWorkingFolder (foldspec +"\"+sf.name, _
                                   remaincount, firsttime, spacer)
    
    next 
    
    'clean up

    set fso = nothing
    
    GetWorkingFolder = foldcount - 1

end function

License

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

cyberneticwraith


Member

Occupation: Web Developer
Location: United States United States

Other popular VBScript articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 11 of 11 (Total in Forum: 11) (Refresh)FirstPrevNext
Generalone more better way. Pinmemberanand choubey11:39 9 Apr '09  
GeneralSystem Volume Information PinmemberSamKost12:02 30 Apr '08  
Generalvb script: open a folder & list its files Pinmemberhitthelink3:28 21 Mar '07  
QuestionACL list of Registry Keys PinmemberGTS20203:06 16 Oct '06  
GeneralBy User PinmemberFluid Dynamics Software5:21 3 Mar '06  
GeneralRe: By User Pinmembercyberneticwraith6:06 3 Mar '06  
Questiongetting Error PinsussAnonymous3:49 28 Sep '05  
AnswerRe: getting Error Pinmembercyberneticwraith6:50 5 Oct '05  
AnswerRe: getting Error PinmemberMichael Weyant21:51 30 Oct '05  
GeneralNice... Pinmemberjalbitz4:42 27 Sep '05  
GeneralRe: Nice... Pinmembercyberneticwraith8:55 27 Sep '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Sep 2005
Editor: Rinish Biju
Copyright 2005 by cyberneticwraith
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project