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 ...
21st May 2009, 12:12 AM #1
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.
IDG Tech News
21st May 2009, 12:20 AM #2
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.
21st May 2009, 12:23 AM #3
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.
21st May 2009, 12:52 AM #4
In batch something like...
Originally Posted by jmair
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.
Thanks to NeoPlosive from:
21st May 2009, 01:20 AM #5
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.
21st May 2009, 03:38 PM #6
Thanks for the info guys, very helpful!
21st May 2009, 11:16 PM #7
I'll post the solution we chose for this issue in case it may be usefull to somebody else in the future.
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.
%comspec% nul /cmd \\servername\sharedfolder\%USERNAME%
xcacls \\servername\sharedfolder\%USERNAME% /t /g "domainname\%USERNAME%":f /y
NET USE u: \\servername\sharedfolder\%USERNAME% /PERSISTENT:No
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.
for /D %%I in (*) DO XCACLS "%%I" /T /G BUILTIN\ADMINISTRATORS:F "NT AUTHORITY\SYSTEM":F "parkco\%%I":F "domainname\teachers":RW "%%I":C
By Chrish5 in forum Windows
Last Post: 1st October 2008, 10:23 AM
By originofsymmetry in forum Scripts
Last Post: 2nd May 2008, 05:13 PM
By FN-GM in forum Scripts
Last Post: 23rd February 2008, 02:08 PM
By mitchell1981 in forum Windows
Last Post: 11th July 2007, 01:33 PM
By wesleyw in forum Windows
Last Post: 30th August 2006, 10:37 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)