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
option explicit
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
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
if firsttime = 1 then
wscript.echo fold.path
foldcount = foldcol.count
firsttime = 0
end if
dim remaincount
remaincount = foldcol.count
dim sf
for each sf in foldcol
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
set fso = nothing
GetWorkingFolder = foldcount - 1
end function