pharaoh fortune slot
ExamNotes.net
Welcome, Guest. Please login or register.
November 23, 2017, 12:58:20 PM

Login with username, password and session length
* Home Help Search Login Register
+  ExamNotes.net
|-+  General discussions
| |-+  Programming Forum
| | |-+  VbScript Question
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: VbScript Question  (Read 1163 times)
mindmesh
Spit Fire
Hero Member
*****
Offline Offline

Posts: 1623

2


View Profile
« on: March 03, 2005, 04:54:29 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
Logged

I take no responsibility for the offensive nature of this post.. If you take offense I am sorry, but honestly don't give a damn. All rights reserved!!
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!