dcsimg
Results 1 to 3 of 3

Thread: I am getting error "Expected End Of Statement"

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2018
    Posts
    2

    I am getting error "Expected End Of Statement"

    The below code I did not write, as I am not very code inclined as far as VB. But I found this and hoped it would help in a pinch. Can anyone help me in figuring out what is wrong and how to correct it.

    The error is "Filename.vbs (7, 31) Microsoft VBScript compilation error: Expected end of statement"

    Const ADS_PROPERTY_APPEND = 3
    Set WshShell = WScript.CreateObject("WScript.Shell")
    '----Get Computer DN------

    Set objADSysInfo = CreateObject("ADSystemInfo")
    ComputerDN = objADSysInfo.ComputerName
    strcomputerdn = "LDAP://" & computerDN
    Set objADSysInfo = Nothing

    '----Connect AD-----

    Set oRoot = GetObject("LDAP://rootDSE")
    strDomainPath = oRoot.Get("defaultNamingContext")
    Set oConnection = CreateObject("ADODB.Connection")
    oConnection.Provider = "ADsDSOObject"
    oConnection.Open "Active Directory Provider"

    'Count = WScript.Arguments.Count
    'For i = 0 To count-1
    Group = EUE_GPO_Test
    'Group = WScript.Arguments(i)
    Addgroup Group
    Next

    '----Get Group DN------
    Function Addgroup(groupname)
    Set oRs = oConnection.Execute("SELECT adspath FROM 'LDAP://" & strDomainPath & "'" & "WHERE objectCategory='group' AND " & "Name='" & GroupName & "'")
    If Not oRs.EOF Then
    strAdsPath = oRs("adspath")
    End If
    If IsEmpty(strAdsPath) = False Then
    Const ADS_SECURE_AUTHENTICATION = 1
    Set objGroup = GetObject(stradspath)
    Set objComputer = GetObject(strComputerDN)
    If (objGroup.IsMember(objComputer.AdsPath) = False) Then
    objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array(computerdn)
    objGroup.SetInfo
    End If
    End If
    End Function

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,118

    Re: I am getting error "Expected End Of Statement"

    Welcome to VBForums

    At some point between the code being written and you using it, there has been a copy+paste issue... replace all instances of & with just &

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2018
    Posts
    2

    Re: I am getting error "Expected End Of Statement"

    Fantastic, Made that change and a few others and now it works like a charm...Thank you for the pointer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width