Create Folder and Amend ACL's

Discussion in 'Scripting' started by Simon G, Mar 13, 2007.

  1. Simon G

    Simon G Guest

    Hello all,

    I am after a script / batch file. Where by it prompts you for the
    samaccountname, then a server/folder and create an account and amend the ACL
    of it....

    Something like this....

    1. Prompt for user id - enter "USERID"
    2. Prompt for server folder - enter "\\sn000001\userfolder\area
    3. Folder gets created \\sn00001\userfolder\area\userid
    4. Permissions are changed on \\sn00001\userfolder\area\userid to include
    "USERID" (Full control) & "Domain Admins" (full control) & "admin group1"
    (full control) & "admin group2"(modify)

    any ideas?

    also what would be even better if step 2 can include some kind of selection
    list. "select 1 for \\sn000001, select 2 for \\sn000002...."
     
    Simon G, Mar 13, 2007
    #1
    1. Advertisements

  2. Simon G

    Golden_au Guest

    the following is the simplfied version of vbs script, you might need add more
    error checking and handling statements to make it perfrect. the essential is
    the "cacls" commandline. it is build in windows dos command, to check the
    usage, just type in cacls /? in command prompt.

    'createfolder.vbs

    'enter info
    userID=inputbox("Enter user ID:")
    Serverpath=inputbox("Enter server path:")
    folderpath=Serverpath & "\" & userID

    ' create folder
    set fs=CreateObject("Scripting.FileSystemObject")

    if not FolderExists(folderpath) then
    set f=fs.CreateFolder(folderpath)
    end if
    set f=nothing
    set fs=nothing

    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run("%COMSPEC% /c Echo Y| cacls " & folderpath & " /t /c /g " &
    chr(34) & "Domain Admini" & Chr(34) & ":F " & chr(34) & userID & chr(34) &
    ":F " & chr(34) & "Admin group1" & chr(34) & ":F " & chr(34) & "Admin group2"
    & chr(34) & ":c ", 2, True)
    WScript.Quit
     
    Golden_au, Mar 15, 2007
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.