Results 1 to 2 of 2
2006-04-11, 14:59 #1
- Join Date
- Mar 2003
- Elkins Park, Pennsylvania, USA
- Thanked 0 Times in 0 Posts
Looping through Folders on a Network Share (WinXP vbscript)
Hi. I hope I'm in the right forum for this...
I am responsible for a set of folders on a network share. This set of folders resides in a single "parent" folder on a share, i.e. in a folder called "Databases" on "servernamedepartmentshare". Within this "Databases" folder are over 100 folders, each dedicated to a different product (e.g. "Product1", "Product2", etc.), and each one containing a database and another folder called "RMAccess". In summary, I have over a hundred RMAccess folders, each in a separate product folder, each with path-/UNC-names like "servernamedepartmentshareDatabasesProduct1RMAccess", "servernamedepartmentshareDatabasesProduct2RMAccess", [/i]ad nauseum[/i].
Now, what I'd like to do is to write a script that will set the correct permissions for each "Productn" folder and also for each "RMAccess" folder within each product folder. (These permissions are not the same, but that's not important right now.)
My problem is that I can't find a sample script anywhere that will successfully loop through all of those folders (although I've managed to find one that successfully loops though folders on my hard-drive). I mean, I can't even get a script to run to list them, let alone set permissions. (I can set the permissions manually, so I know I have the right priveleges for it, and I'll most likely be using XCACLS to do it.)
Does anyone have any experience doing this? I'm experienced in VB/VBA, but I'm stumped here. In the length of time it's taken me to stop and ask for directions, I could have done them ALL manually, but now it's the principle of the thing!!<font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike
2006-04-11, 15:12 #2
- Join Date
- Mar 2002
- Thanked 29 Times in 29 Posts
Re: Looping through Folders on a Network Share (WinXP vbscript)
I cannot help you with the permissions, but here is a simplistic way to get the folder names:
' Modify path as needed, but keep trailing backslash
Const strParent = "servernamedepartmentshareDatabases"
Dim strProduct As String
Dim strPath As String
strProduct = Dir(strParent, vbDirectory)
Do While Not strProduct = ""
If Not (strProduct = ".." Or strProduct = ".") Then
' This is the path of the folder you want:
strPath = strParent & strProduct & "RMAccess"
' Code to do something with the folder goes below
strProduct = Dir