Re: create a share folder on a remote computer



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




.



Relevant Pages

  • Re: label in footertemplate of datagrid
    ... Sub dlCart_ItemDataBound(sender As Object, e As DataListItemEventArgs) ... dblTotal = 'calling a function which returns a Double ... Dim TotalLabel As Label = CType, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Event enqueing in PostMessage style
    ... >> invoked not earlier as the calling thread returns to the central message ... >> meaning that the event handler is called immediately and interrupts the ... >> Private WithEvents MyEventObj As New MyEventClass ... >> Private Sub MyHandler() Handles MyEventObj.MyEvent ...
    (microsoft.public.dotnet.general)
  • Re: late binding
    ... If the method from objvar.PerformsomeAction is calling the GC or by instance ... than it works in my opinion. ... Dim objVar as new foo ... End Sub ...
    (microsoft.public.dotnet.languages.vb)
  • Re: What am i doing wrong in calling this script? Urgent please. Thank You.
    ... > Sub btnFinish_Click ... > I just uploaded a web site and i am getting an error. ... > I have a script which sends form values to an email using AspNetEmail. ... > So i am calling the script in the wrong way. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Working with all files in directory
    ... In answer to you question about what PrepareWCLineCount actually does: ... Are you saying that there is no way to return to the calling program after ... Dim pDoc As Word.Document ... Sub PrepareWCLineCount() ...
    (microsoft.public.word.vba.general)