+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
Windows Server 2008 Thread, Creating User folder heirarchy with scripting or program in Technical; Originally Posted by dhicks "cacls" is a command line utility used for setting permissions on file shares: Set Permissions for ...
  1. #16
    jlondon's Avatar
    Join Date
    Jun 2010
    Location
    Minneapolis
    Posts
    12
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by dhicks View Post
    "cacls" is a command line utility used for setting permissions on file shares:

    Set Permissions for Shared Folders

    Just use it from your favourite scripting language, however that scripting language runs command-line utilities. Probably best to try it from a command prompt, manually, yourself first to see if it works correctly.

    --
    David Hicks
    David, If you are wanting to quote me please note the entire posting was this:
    David, I am not up on setting cacls but if it would work would be happy to try. Is this how you set your users folder up? I am trying to get examples of how other Network Managers go about setting up their users folders.
    If you don't have experience with including cacls in scripting, please accept my thanks for your time and I will let you know what comes of this.

  2. #17
    jlondon's Avatar
    Join Date
    Jun 2010
    Location
    Minneapolis
    Posts
    12
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    VB script to create the folders just need to set permissions

    Ok, I have a script here that creates the folders, now does anyone have experience with calcs that will help me set permissions ?

    Code:
    Option Explicit
    Dim objFSO
    On Error Resume Next
     Set objFSO = CreateObject("Scripting.FileSystemObject")
     ProcessScript
     If Err.Number <> 0 Then
      Wscript.Quit
     End If
    On Error Goto 0
    '-------------------------------------------------------------------------------------------------
    'Functions Processing Section
    '-------------------------------------------------------------------------------------------------
    'Name  : ProcessScript -> Primary Function that controls all other script processing.
    'Parameters : None   ->
    'Return  : None   ->
    '-------------------------------------------------------------------------------------------------
    Function ProcessScript
     Dim userNames, userName
     Dim folderSpec, folderNames, folderName 
     folderSpec = "C:\Data\Homedrives"
     userNames = Array("user1","user2","user3")
     folderNames = Array("Public","Private","Dropbox")
     '----------------------------------------------------------------------------------------------
     'Create the folder structure for each user.
     '----------------------------------------------------------------------------------------------
     For Each userName In userNames
      Do
       If Not CreateFolder(folderSpec & "\" & userName) Then
       Exit Do
       End If
       For Each folderName In folderNames
       Do
        If Not CreateFolder(folderSpec & "\" & userName & "\" & folderName) Then
         Exit Do
        End If
       Loop Until True
       Next
      Loop Until True
     Next
    End Function
    '-------------------------------------------------------------------------------------------------
    'Name  : CreateFolder -> Recursive Function to Create a directory structure or single folder.
    'Parameters : folderSpec -> Path of folder\folders to create.
    'Return  : CreateFolder -> Returns True if the directory structure was successfully created otherwise False.
    '-------------------------------------------------------------------------------------------------
    Function CreateFolder(folderSpec)
     CreateFolder = False
     If Not objFSO.FolderExists(folderSpec) Then
      If InStrRev(folderSpec, "\") <> 0 Then
       If Not CreateFolder(Left(folderSpec, InStrRev(folderSpec, "\") - 1)) Then
       Exit Function
       End If
      End If
      On Error Resume Next
       objFSO.CreateFolder folderSpec
       If Err.Number <> 0 Then
       Exit Function
       End If
      On Error Goto 0
     End If
     CreateFolder = True
    End Function

  3. #18

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,611
    Thank Post
    1,226
    Thanked 772 Times in 670 Posts
    Rep Power
    234
    Quote Originally Posted by jlondon View Post
    Ok, I have a script here that creates the folders, now does anyone have experience with calcs that will help me set permissions?
    Have you tried running cacls to change a folder's permissions from the command line - can you get it to work okay from there? Searching for "cacls folder permissions" on Google brings up these two links:

    CACLS - Windows utility modifify access control ACL
    How To Automate Folder Permissions

    which would seem to include step-by-step command-line examples and some example VBScript code.

    Have you done much programming/scripting before, or are you simply trying to get a problem solved as best you can by pasting in code and hoping it works? Unless I've got the wrong idea here, the problem you are trying to solve is quite simple (make a bunch of folders, assign permissions) - do you need some help writing a script from scratch to get what you want done?

    --
    David Hicks

  4. #19
    jlondon's Avatar
    Join Date
    Jun 2010
    Location
    Minneapolis
    Posts
    12
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Script for creating user folders with 3 sub folders. Public, Private, and Dropzone

    Success! I am passing along this script for others to use. Let me give you some history on these user folders. Nested in the user folder, you have three sub folders that allow for one to be private where only the user and admins have access, one to be a dropbox where other users can put files but not access, and one to be completely public where other users can put files but not delete them.
    A huge thank you to Matthew Beattie on Technet for writing this script! I can now put the vb book away.. for now :-)

    The sample user file and script are attached.
    Best Regards,
    Joe
    Attached Files Attached Files

  5. #20
    jlondon's Avatar
    Join Date
    Jun 2010
    Location
    Minneapolis
    Posts
    12
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    David,
    Thank you for all of the effort you put forth in sharing your knowlege both of Vb scripting but also of cacls. I am not a programmer by trade so to answer your question, yes I was looking for sample code to paste and test (Hoping it works)

    Kind Regards,
    Joe London

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Creating Home Folder.. and getting it to map for users
    By dgrams in forum How do you do....it?
    Replies: 16
    Last Post: 26th February 2010, 05:15 PM
  2. Replies: 3
    Last Post: 10th July 2009, 03:11 PM
  3. Delete a folder using scripting
    By FN-GM in forum Scripts
    Replies: 15
    Last Post: 22nd December 2007, 04:44 PM
  4. Creating a B2D folder on a LinkStation
    By randle in forum Windows
    Replies: 0
    Last Post: 22nd August 2007, 09:45 AM
  5. Replies: 3
    Last Post: 16th November 2006, 09:55 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •