Re: create a share folder on a remote computer

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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: Halt code without resetting
    ... Public Sub MainSub() ... ' Continue with other processing in this routine ... Private Function SubFunction1() As fnReturnValues ... ' Stop processing in this function and stop processing by calling ...
    (microsoft.public.access.modulesdaovba)
  • Help with error trapping and raising
    ... The error received by the CALLING routine of the procedure below is: ... Public Sub wsm_sendSMS(ByVal str_id As String, ByVal str_password As String, ... 'This subroutine is the class error handler. ...
    (microsoft.public.access.modulesdaovba)
  • 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: 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: 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)