RE: share a folder from a remote computer
- From: /\/\o\/\/ <o@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 21 Nov 2005 00:32:03 -0800
in Vbscript :
found it in the WSH walkthrough :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wswlkwshwalkthrough.asp
Set Services =
GetObject("WINMGMTS:{impersonationLevel=impersonate,(Security)}!" &
AdminServer & "\ROOT\CIMV2")
Set SecDescClass = Services.Get("Win32_SecurityDescriptor")
Set SecDesc = SecDescClass.SpawnInstance_()
Set Trustee = Services.Get("Win32_Trustee").SpawnInstance_
Trustee.Domain = Null
Trustee.Name = "EVERYONE"
Trustee.Properties_.Item("SID") = Array(1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0)
Set ACE = Services.Get("Win32_Ace").SpawnInstance_
ACE.Properties_.Item("AccessMask") = 2032127
ACE.Properties_.Item("AceFlags") = 3
ACE.Properties_.Item("AceType") = 0
ACE.Properties_.Item("Trustee") = Trustee
SecDesc.Properties_.Item("DACL") = Array(ACE)
Set Share = Services.Get("Win32_Share")
Set InParam = Share.Methods_("Create").InParameters.SpawnInstance_()
InParam.Properties_.Item("Access") = SecDesc
InParam.Properties_.Item("Description") = "Public Share"
InParam.Properties_.Item("Name") = ShareName
InParam.Properties_.Item("Path") = FolderName
InParam.Properties_.Item("Type") = 0
Share.ExecMethod_("Create", InParam)
gr /\/\o\/\/
"TomKing" wrote:
> I am totally new to VBScript. But somehow I can understand your script a
> little bit. The logical is not hard to learn but I can not transfer it to
> VBScript. So can you please provide a VBScript version :P
>
> What I really want is using a vbs retrieve info from a Excel Spread*** to
> do all the tasks. If using XCACLS.VBS I may have to type the username and
> home directory by hand! I believe there are a lot others have the same
> problem. So please help us.
>
> "/\/\o\/\/" wrote:
>
> >
> > "TomKing" wrote:
> >
> > > I have a script create users and home direcotries at the same time.
> > > Now the only problem I have is sharing.
> > > The home directory is on a file server, I want to know how to assign share
> > > permissions to the user.
> > > I got a script like:
> > >
> > > Const FILE_SHARE = 0
> > > Const MAXIMUM_CONNECTIONS = 25
> > > strComputer = "file-server"
> > > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> > > Set objNewShare = objWMIService.Get("Win32_Share")
> > > errReturn = objNewShare.Create("C:\student\student1", "student1$",
> > > FILE_SHARE, MAXIMUM_CONNECTIONS, "share for student1")
> > >
> > > But this one just share the folder for everyone, I want it just for user
> > > "student1" and "file-server\\administrators". Could anyone tell me how to
> > > change this script?
> > >
> > > Thanks.
> > >
> >
> > You need to set the ShareInfo object on the share,
> >
> > you need to construct an Security descriptor for this using the following
> > WMI classes:
> >
> > Win32_SecurityDescriptor
> > Win32_ace
> > win32_trustee
> >
> > I posted a Example in MSH for this before (it will take some effort
> > translating this to VbScript but it will give some indication how to
> > construct the security descriptor) :
> >
> > http://mow001.blogspot.com/2005/11/replace-security-on-existing-share.html
> >
> > gr /\/\o\/\/
> >
.
- Follow-Ups:
- RE: share a folder from a remote computer
- From: TomKing
- RE: share a folder from a remote computer
- Prev by Date: Re: create a share folder on a remote computer
- Next by Date: RE: share a folder from a remote computer
- Previous by thread: Re: create a share folder on a remote computer
- Next by thread: RE: share a folder from a remote computer
- Index(es):