Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
| Search | Today's Posts | Mark Forums Read
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 13th, 2007, 03:26 PM
Authorized User
Points: 216, Level: 4
Points: 216, Level: 4 Points: 216, Level: 4 Points: 216, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2005
Location: Honoulu, HI, USA.
Posts: 47
Thanks: 2
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote




Similar Threads
Thread Thread Starter Forum Replies Last Post
URLEncoding(UTF-8) creating problems in Tomcat 6.0 SambaLH BOOK: Expert One-on-One J2EE Design and Development 0 September 19th, 2008 08:49 AM
Creating folders on network share JonniP Access VBA 1 January 3rd, 2007 03:51 PM
problems in creating dynamic controls merinmathew ASP.NET 1.0 and 1.1 Basics 0 January 12th, 2006 01:06 AM
creating a list of folders hillbilly geek PHP How-To 1 December 28th, 2005 09:32 AM
Access Problems. Creating a Transition Table rumblepup Access 6 December 23rd, 2003 06:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.