Site Maintenance this evening The site will be offline for hosting changes. Time TBC

+ Post New Thread
Results 1 to 7 of 7
Scripts Thread, VBS to Create Folder, Share it and Set Permissions on It. in Coding and Web Development; I'm trying to piece together VBScript that will be run from the server on the client side at login. It ...
  1. #1
    jmair's Avatar
    Join Date
    Aug 2007
    Posts
    274
    Thank Post
    58
    Thanked 9 Times in 9 Posts
    Rep Power
    16

    VBS to Create Folder, Share it and Set Permissions on It.

    I'm trying to piece together VBScript that will be run from the server on the client side at login. It will get the user name and create a folder with that name on the server. So far so good.

    I'm having troubles actually sharing the folder with the user having permissions.

    How can I 'Share' the folder and give the permissions that I want?

    Any thoughts or where can I go to get this info, my googl-fu couldnt find it.

  2. #2
    User3204's Avatar
    Join Date
    Aug 2006
    Location
    Wirral
    Posts
    769
    Thank Post
    55
    Thanked 66 Times in 62 Posts
    Rep Power
    34
    Go here How to use Xcacls.vbs to modify NTFS permissions and download their VBS file.

    I use this as part of new user creation, after I have another script to create the user folder.

  3. #3

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,262
    Thank Post
    242
    Thanked 1,568 Times in 1,250 Posts
    Rep Power
    340
    I have a small application I bought years ago which converts a list from a notepad file into folders which is handy. You probably could do this with a script. As for sharing and permissions, take a look at Scriptlogic's Autoshare.

  4. #4

    Join Date
    Dec 2008
    Posts
    197
    Thank Post
    7
    Thanked 32 Times in 18 Posts
    Rep Power
    18
    Quote Originally Posted by jmair View Post
    I'm trying to piece together VBScript that will be run from the server on the client side at login. It will get the user name and create a folder with that name on the server. So far so good.

    I'm having troubles actually sharing the folder with the user having permissions.

    How can I 'Share' the folder and give the permissions that I want?

    Any thoughts or where can I go to get this info, my googl-fu couldnt find it.
    In batch something like...

    xcacls.exe "\\Server\FolderRoot\%Username%" /E /T /C /R /G "%Username%":M /Y

    Should work... untested was just off the top of my head...

    I'm not a VBS guy but I suppose you could either call a .bat or do it completely in batch or get someone to help you convert it all into vbs.

  5. Thanks to NeoPlosive from:

    jmair (21st May 2009)

  6. #5
    contink's Avatar
    Join Date
    Jul 2006
    Location
    South Yorkshire
    Posts
    3,791
    Thank Post
    303
    Thanked 327 Times in 233 Posts
    Rep Power
    118
    You might want to take a look at my script here:
    My Docs, Class Shared & Shortcut generator

    ... it does a lot of what you want to do plus a few other bits. If nothing else it would certainly provide a good example to help with your own script.

    In terms of sharing I'd recommend creating a single shared folder manually for all users, set the Share perms to EVERYONE FULL and then tie down access using the NTFS security groups and perms. The script above, uses xcacls.vbs to handle the folder permissions for the end user so that's really the only hard bit.


    FYI: I'm in the process of updating my script again, most likely sometime tomorrow, so expect a new release that should finish things off a bit more.

  7. #6
    jmair's Avatar
    Join Date
    Aug 2007
    Posts
    274
    Thank Post
    58
    Thanked 9 Times in 9 Posts
    Rep Power
    16
    Thanks for the info guys, very helpful!

  8. #7
    jmair's Avatar
    Join Date
    Aug 2007
    Posts
    274
    Thank Post
    58
    Thanked 9 Times in 9 Posts
    Rep Power
    16
    I'll post the solution we chose for this issue in case it may be usefull to somebody else in the future.

    Code:
    @ECHO on
    
    %comspec% nul /cmd \\servername\sharedfolder\%USERNAME%
    
    xcacls \\servername\sharedfolder\%USERNAME% /t /g "domainname\%USERNAME%":f /y
    
    NET USE u: \\servername\sharedfolder\%USERNAME% /PERSISTENT:No
    After playing for a while, I've chosen this to solve the issue. It's a quick batchfile that i'm running as a login script from an OU named after the graduation year of the students. The share needs to be read/write/execute in order for the folder to be created (although the dont have access to the root of the shared folder I'll be running the below batch file afterhours.


    Resides inside the shared folder. This batch removes all security permissions from each folder inside the share. It the adds admin full permissions and username permission to full, and gives teachers read and write access.
    Code:
    for /D %%I in (*) DO XCACLS "%%I" /T /G BUILTIN\ADMINISTRATORS:F "NT AUTHORITY\SYSTEM":F "parkco\%%I":F "domainname\teachers":RW "%%I":C
    pause

SHARE:
+ Post New Thread

Similar Threads

  1. Permissions for VBS
    By Chrish5 in forum Windows
    Replies: 6
    Last Post: 1st October 2008, 09:23 AM
  2. Create a hidden share for home directories
    By originofsymmetry in forum Scripts
    Replies: 5
    Last Post: 2nd May 2008, 04:13 PM
  3. VBS Script to copy a folder
    By FN-GM in forum Scripts
    Replies: 2
    Last Post: 23rd February 2008, 01:08 PM
  4. Bulk Modify Share Permissions
    By mitchell1981 in forum Windows
    Replies: 4
    Last Post: 11th July 2007, 12:33 PM
  5. Share Permissions
    By wesleyw in forum Windows
    Replies: 6
    Last Post: 30th August 2006, 09:37 AM

Thread Information

Users Browsing this Thread

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

Posting Permissions

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