Problems with creating folders
Hi all,
I have a problem with creating home folders on a share. Here is the code:
Const WAIT_ON_RETURN = True
Const HIDE_WINDOW = 0
Const USER_ROOT_UNC = "\\server\drive"
Dim objDomain
Dim objUser
Dim vReturn
Dim WshShell, WshNetwork, objFS, strUser
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")
ReDim vReturn(0)
' Connect to the domain
Set objDomain = GetObject("LDAP://ou=cool,dc=stock,dc=com")
' apply a filter to retrieve only objects of class User
objDomain.Filter = Array("User")
' iterate all user objects within the container
For Each objUser In objDomain
If objUser.class = "user" then
If Trim(vReturn(0)) <> "" Then
ReDim Preserve vReturn(UBound(vReturn) + 1)
End If
vReturn(UBound(vReturn)) = objUser.samAccountName
strUser = objUser.sn & "." & objUser.givenName
End If
If objFS.FolderExists("") Then
Call objFS.CreateFolder("USER_ROOT_UNC & "\" & strUser")
Call WshShell.Run("cacls " & USER_ROOT_UNC & "\" & strUser & _
" /e /g Administrator:F", HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("cacls " & USER_ROOT_UNC & "\" & strUser & _
" /e /g " & strUser & ":C", HIDE_WINDOW, WAIT_ON_RETURN)
Else
End If
Next
Highlighted in red is the area that I am having problems with. Basically I know that you can have this code echo out everytime that a folder exists and hit ok and it will continue on. But what if there are hundreds of folders? So I want the code to just continue on if it comes to an existing folder. Any assistance would be greatly appreciated.
Thanks
Chris
|