Home > Archive > Programming Forum > March 2005 > VbScript Question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author VbScript Question
mindmesh

2005-03-03, 2:54 pm

This script only enumerates the files in a specified folder, how do I get it to enumerate thru all folders and output the files? Thanks.



Option Explicit
On Error Resume Next
Dim folder
folder = Inputbox("Which drive do you want to check?")
getFolder(folder)

Function getFolder(root)

Dim fso, folders, folder, file, files, txtFile
Const Appending = 8

Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FolderExists(root) Then
Set txtFile = fso.createtextfile("C:\Owners.txt", False)
If err.number <> 0 then
Set txtFile = fso.opentextfile("C:\Owners.txt", Appending)
End If



txtFile.WriteLine root & "," & getOwner(root)
For Each file In fso.GetFolder(root).Files
txtFile.WriteLine file & "," & getOwner(fso.GetAbsolutePathName(file))
Next
For Each folder In fso.getFolder(root).SubFolders
getFolder(fso.GetAbsolutePathName(folder))
Next
Else
WScript.Echo "Folder doesn't exist: " & root
Exit Function
End If
End Function

Function getOwner(object)
Dim su, sd
Set su = CreateObject("ADsSecurityUtility")
Set sd = su.GetSecurityDescriptor(object, 1, 1)
getOwner = sd.Owner
End Function
Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net