How do I assigning/modifying access to shared folders using VBscripts?

I have created a shared folder using a VBscript. The default access is for
EVERYBODY. Now I want to remove this EVERYBODY and add a specific user with
read/write access.

I haven't found anything on this anywhere. I guess AD is not designed/meant
for this. In our environment (University lab) I think it is the only
solution. Everybody is using laptops where they want to work in different
networks. We have a central file server (running windows server 2003, AD)
where data is stored for them in a user specific way. Now users should only
be able to access their designated folder and one shared folder. Others
should not have any access to the designated folder.

Maybe someone can also comment on the solution. Since I am getting
frustrated reading all the documentations not being able to find what I am
looking for.

Thanks a lot in advance.

Bernd

Re: assigning/modifying access to shared folders using VBscripts by Torgeir

Torgeir
Fri Dec 03 15:10:38 CST 2004

Bernd wrote:

> How do I assigning/modifying access to shared folders using VBscripts?
>
> I have created a shared folder using a VBscript. The default access
> is for EVERYBODY. Now I want to remove this EVERYBODY and add a
> specific user with read/write access.
Hi

Some options:

A)
You can use Microsoft's RMTShare.exe to set permission on a share:

Q. How can I modify share permissions from the command line?
http://www.windows2000faq.com/Articles/Index.cfm?ArticleID=14459
RMTShare.exe: http://www.jsiinc.com/asp/reghacks.asp?tipnumb=6353


B)
SETACL (freeware) at http://setacl.sourceforge.net/ is also an option.
SetACL can set permissions on:

Local or remote directories
Local or remote files
Local or remote printers
Local or remote registry keys
Local or remote Win32 services
Local or remote network shares


C)
You can set the security descriptor for the shares with WMI..

SetSecurityDescriptor
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/setsecuritydescriptor_method_in_class_win32_logicalsharesecuritysetting.asp

Here is a couple of examples on the SetSecurityDescriptor method in Class
Win32_LogicalShareSecuritySetting (disregard that they use
wbemscripting.swbemlocator instead of winmgmts:, the rest will be the same):

From: Max L. Vaughn (maxvonline@microsoft.com)
Subject: RE: Add User to sharefolder
Newsgroups: microsoft.public.platformsdk.adsi
Date: 2001-11-16 14:01:51 PST
http://groups.google.com/groups?selm=ejzoroubBHA.253%40cppssbbsa01.microsoft.com

From: [MS] Tim Chen (timchen2000@hotmail.com)
Subject: Re: Folder Security
Newsgroups: microsoft.public.win32.programmer.wmi
Date: 2002-06-13 13:06:05 PST
http://groups.google.com/groups?selm=3d08f9d7%241%40news.microsoft.com



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx