I have cobbled this together by ripping out parts of a script I have and altering bits. With some testing it should work.... I think :/ Copy and paste into notepad and save as a .vbs
Code:
' Map a temporary network drive to year folder (root)
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "Q:", "\\server\share\year"
' Dump the list of folder names into a CSV file for use later
' To do this open a command prompt and use DIR command
intshort = 100
strDump = "dir /b >c:\yearx.csv"
objShell.Run "cmd"
Wscript.Sleep intshort
objShell.SendKeys strDump
objShell.SendKeys "{ENTER}"
Wscript.Sleep intshort
objShell.SendKeys "exit"
objShell.SendKeys "{ENTER}"
' Define a variable to use for the folder name
Dim strFolderName
' Read the contents of newly created CSV into an array
Const ForReading = 1
Set objFSO = Nothing
set objTextFile = Nothing
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\yearx.csv", ForReading)
Do While objTextFile.AtEndOfStream <> True
strNextLine = objTextFile.Readline
arrUSERData = split(strNextLine, ",")
strFolderName = arrUSERData(0)
' Use xcacls to set NTFS permissions
' This opens a command prompt and feeds the xcacls and variable into the line
' First command removes the old setting, second one creates the new one
intshort = 100
Set objShell = CreateObject("WScript.Shell")
strPart1 = "xcacls q:\"
strPart2 = " /R "
strPart3 = " /T /E /C /G "
objShell.Run "cmd"
Wscript.Sleep intshort
objShell.SendKeys strPart1 & strFolderName & strPart2 & strFolderName
objShell.SendKeys "{ENTER}"
objShell.SendKeys strPart1 & strFolderName & strPart3 & strFolderName
objShell.SendKeys "{ENTER}"
Wscript.Sleep intShort
' Clear the variable for the next pass through
set strFolderName = Nothing
Loop
' Close text file
objTextFile.Close
' Remove the temporary network drive
DriveLetter1 = "Q:"
objNetwork.RemoveNetworkDrive Driveletter1, "True", "True"