Re: create a share folder on a remote computer
- From: "Michael Harris \(MVP\)" <mikhar at mvps dot org>
- Date: Sun, 20 Nov 2005 20:07:05 -0800
TomKing wrote:
> I have following script to create a share folder on a remote computer.
> Got error message says:"share.vbs(24,36) compilation error: Cannot use
> parentheses when calling a sub"
>
> Can anyone tell me what's wrong with the last line? I cannot use
> bracket there?
Share.ExecMethod_ "Create", InParam
or
Call Share.ExecMethod_("Create", InParam)
Consult the VBScript documentation for the difference in calling syntax
between calling a Sub versus a Function. When calling a Sub (as opposed to a
Function), arguments are not enclosed in ()s unless you use the option Call
statement.
>
> strComputer = "file-server"
> strHomeDirect = "D:\test"
>
> Set Services = GetObject("WINMGMTS:\\" & strComputer & "\ROOT\CIMV2")
> Set SecDescClass = Services.Get("Win32_SecurityDescriptor")
> Set SecDesc = SecDescClass.SpawnInstance_()
> Set Trustee = Services.Get("Win32_Trustee").SpawnInstance_
> Trustee.Domain = "academic"
> Trustee.Name = "test"
> 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") = "Test Share"
> InParam.Properties_.Item("Name") = ShareName
> InParam.Properties_.Item("Path") = strHomeDirect
> InParam.Properties_.Item("Type") = 0
> Share.ExecMethod_("Create", InParam)
--
Michael Harris
Microsoft MVP Scripting
.
- Prev by Date: Re: When do i need [void]?
- Next by Date: RE: share a folder from a remote computer
- Previous by thread: [msh] output of append command of stringbuilder
- Next by thread: RE: share a folder from a remote computer
- Index(es):
Relevant Pages
|