morijona
asked on
Vbs that List folder & subfolder Permission
Hi all,
I'm trying to build a script that List folder and subfolder Permission and stop at 3 depth of my source Folder.
Here's what i got
I'm trying to build a script that List folder and subfolder Permission and stop at 3 depth of my source Folder.
Here's what i got
Option explicit
Dim fso, fldr, fc, f1 ,fldname, usrname, srcFile, shell
on error resume next
set FSO = Wscript.CreateObject("scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")
fldname = "F:\departement\finances" '<---- change to top directory
DeleteFiles = FSO.GetFolder(fldname)
Set fldr = fso.GetFolder(fldname)
Recurse fldr
Set fldr = Nothing
Set fso = Nothing
Wscript.Quit
Public Sub Recurse( ByRef fldr)
dim subfolders,folder
Dim srcFile, liste, rapport
Set subfolders = fldr.SubFolders
inc=0
'************** Recurse all of the subfolders.
dim fldrsize, inc, shell
Set shell = CreateObject("WScript.Shell")
For Each folder in subfolders
wscript.sleep 1000
inc=inc+1
if inc<3 then
shell.run "cmd /c c:\xcacls.vbs " & folder & " >> c:\report\finances.txt"
Recurse folder
end if
next
End Sub
ASKER
thanks but my main problem and i dont have any idea how to do that its only to get the acl only on 3 folder depth.
ex: c:\folder1\folder2\folder3 \folder4
and get the ACL on folder 1, folder 2, folder 3 and discard further foler.
Any idea?
ex: c:\folder1\folder2\folder3
and get the ACL on folder 1, folder 2, folder 3 and discard further foler.
Any idea?
You can use the subfolders property of the folder you are currently in.
As far as just going from Folder, to SubFolder, to SubFolder. I think the only way to do that is to have a counter set at 1 before you call the sub and include it as one of the parameters of the sub. Then before you call the sub from within the sub increment it by 1 and then do an If cnt < 3 then do the sub.
As far as just going from Folder, to SubFolder, to SubFolder. I think the only way to do that is to have a counter set at 1 before you call the sub and include it as one of the parameters of the sub. Then before you call the sub from within the sub increment it by 1 and then do an If cnt < 3 then do the sub.
Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
s = s & f1.name
s = s & vbCrLf
Next
MsgBox s
End Sub
ASKER
I just did it but my script got and error because it search too much folder.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window