Jump to content

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


Recommended Posts

Posted

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.

Posted
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.
Posted
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.

  • Thanks 1
Posted

You might want to take a look at my script here:

http://www.edugeek.net/forums/scripts/6750-my-docs-class-shared-shortcut-generator.html

 

... 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.

Posted

I'll post the solution we chose for this issue in case it may be usefull to somebody else in the future.

 

@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.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...