Displaying directory structure using text/ascii

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
neil.illsley@tegel.co.nz
Posts: 3
Joined: Mon Jun 04, 2007 11:53 am

Displaying directory structure using text/ascii

Post by neil.illsley@tegel.co.nz »

Hi,

I'm writing a script to crawl a directory structure and output NTFS-security at the folder level. I've written everything but I can't get it to display the folder structure correctly.

Does anyone have any samples of vbscript being used to display a directory tree?

Thanks in advance.

Sam.

User avatar
neil.illsley@tegel.co.nz
Posts: 3
Joined: Mon Jun 04, 2007 11:53 am

Displaying directory structure using text/ascii

Post by neil.illsley@tegel.co.nz »

Yep.

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

Displaying directory structure using text/ascii

Post by jhicks »

Using the FileSystem object is easy enough to display folder names, but formatting it with tabs or spaces to indicate the proper nesting is trickier. I might have an old script that does something like this but I'll have to dig to find it.

jvierra
Posts: 14543
Joined: Tue May 22, 2007 9:57 am
Contact:

Displaying directory structure using text/ascii

Post by jvierra »

function DisplayFolders( nTablEvel, oFolders )
nTabLevel - nTabLevel + 1

' call next level with this
if oFolders.Folders <> Nothing Then
DisplayFolders nTabLevel, oFolders.Folders
End If

'''''
End Function


Call recursively and increment nTabLevel at the beginning of the call. This can then be used to add nTabLevel tabs to teh front of the output line.


User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

Displaying directory structure using text/ascii

Post by jhicks »

I hate re-inventing the wheel.

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

Displaying directory structure using text/ascii

Post by jhicks »

That was my first thought but I think Samd wants to display the tree along side other information.

User avatar
neil.illsley@tegel.co.nz
Posts: 3
Joined: Mon Jun 04, 2007 11:53 am

Displaying directory structure using text/ascii

Post by neil.illsley@tegel.co.nz »

I want to do a crawl of a directory structure to return ACL info. Because the directory structure's I'm talking about are huge I need the output to be in an easily readable format rather than just a list.
Thanks for your help guys.

Sam.

jvierra
Posts: 14543
Joined: Tue May 22, 2007 9:57 am
Contact:

Displaying directory structure using text/ascii

Post by jvierra »

Good luck on the S4ecurity Descriptors.

Consider using SUBINACL (Resource Kit) to get teh display as SDDL. The binary form is pretty nasty to display.

SUBINACL returns a file like this:

Code: Select all

	
+File c:Documents and Settings
/sddl=O:BAG:SYD:(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;BU)(A;;0x1200a9;;;PU)(A;;0x1200a9;;;WD)(A;OICIIO;GA;;;SY)(A;OICIIO;GA;;;BA)(A;OICIIO;GXGR;;;BU)(A;OICIIO;GXGR;;;PU)(A;OICIIO;GXGR;;;WD)
	
+File c:MSOCache
/sddl=O:BAG:BAD:(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)
	
+File c:Program Files
/sddl=O:BAG:SYD:PARAI(A;;0x1200a9;;;BU)(A;OICIIO;GXGR;;;BU)(A;;0x1301bf;;;PU)(A;OICIIO;SDGXGWGR;;;PU)(A;;FA;;;BA)(A;OICIIO;GA;;;BA)(A;;FA;;;SY)(A;OICIIO;GA;;;SY)(A;;FA;;;BA)(A;OICIIO;GA;;;CO)
	
+File c:quarantine
/sddl=O:S-1-5-21-1417001333-789336058-1060284298-1003G:S-1-5-21-1417001333-789336058-1060284298-513D:(A;OICI;FA;;;BA)(A;OICI;FA;;;SY)(A;;FA;;;S-1-5-21-1417001333-789336058-1060284298-1003)(A;OICIIO;GA;;;CO)(A;OICI;0x1200a9;;;BU)(A;CI;LC;;;BU)(A;CI;DC;;;BU)

All you need to do is to parse the file and reformat it to display as a tree. SUBINACL can be set to only return folders along with selectively returning DACL, SACL, flags, owner. It is the only utility that can manage security on ALL objects in Windows NT.

By the way. The output is easy to parse. Just look for the "+" at teh beginning of a line and you havetje folder/file name then take the next line as the SDDL then look for the next "+".

The file is Unicode and will have to be converted but that's very easy.



jvierra2007-06-05 21:29:30

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

Displaying directory structure using text/ascii

Post by jhicks »

If you can, please put this in the Script Vault for posterity. Forum posts will eventually fade away.

Locked