psexec syntax error within VB macro.

shauli 1 Reputation point
2020-12-31T13:16:03.487+00:00

Hi Guys,
I am trying to use psexec to start a program on a remote computer. I embedded the code :
psexec -i -s -d \REMOTECOMPUTERNAME -u USER -p PASSWORD “C:\Program Files\LightBurn\LightBurn.exe”
(which working well by itself) inside a Visual Basic code and I am getting a syntax error. I guess VB don't like the parenthesis in the psexec argument.

This is the line in question and I hope someone can offer solution.


Call Shell("psexec -i -s -d \REMOTECOMPUTERNAME -u USER -p PASSWORD “C:\Program Files\LightBurn\LightBurn.exe” " & """" & out_file & """", vbNormalFocus)

End Sub

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,741 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Viorel 118.2K Reputation points
    2020-12-31T14:33:51.02+00:00

    Try the next statement:

    Shell("psexec -i -s -d \REMOTECOMPUTERNAME -u USER -p PASSWORD ""C:\Program Files\LightBurn\LightBurn.exe"" """ & out_file & """", vbNormalFocus)
    
    0 comments No comments

  2. shauli 1 Reputation point
    2020-12-31T14:45:51.377+00:00

    Thanks Viorel-1

    still getting the same compile error: Expected list separator or ).


  3. shauli 1 Reputation point
    2020-12-31T15:13:16.807+00:00

    This is a macro within CorelDraw (CorelDraw have a VB editor for Macros). Basically it will copy the selection in coreldraw and open it in another program LightBurn.
    The script work well when both programs are on the same PC. using the code:
    Call Shell("C:\Program Files\LightBurn\LightBurn.exe " & """" & out_file & """", vbNormalFocus)

    I am trying to open the program LightBurn on another machine on the local network using psexec
    (typing directly in CMD window: psexec -i -s -d \REMOTECOMPUTERNAME -u USER -p PASSWORD “C:\Program Files\LightBurn\LightBurn.exe
    will do it.

    Enclosed bellow is the original code that work when both programs on the same machine:

    Sub removeDup()
    'variables
    Dim sr As ShapeRange
    Dim srKeep As New ShapeRange
    Dim dupFound As Boolean

    Dim shape As shape
    Dim keepShape As shape
    
    'set variables
    Set sr = ActivePage.Shapes.FindShapes()
    
    For Each shape In sr.Shapes
        dupFound = False
        If srKeep.Count > 0 Then
            For Each keepShape In srKeep.Shapes
                 If keepShape.PositionX = shape.PositionX Then
                         If keepShape.PositionY = shape.PositionY Then
                                 If keepShape.SizeHeight = shape.SizeHeight Then
                                         If keepShape.SizeWidth = shape.SizeWidth Then
                                                 sr.DeleteItem (sr.IndexOf(shape))
                                                 dupFound = True
                                                 Exit For
                                         End If
                                 End If
                         End If
                 End If
            Next keepShape
            If Not dupFound Then
                 srKeep.Add shape
                 dupFound = False
            End If
        Else
            srKeep.Add shape
        End If
    Next shape
    

    End Sub
    Sub Lightburn()
    Dim answer As Integer
    Dim OrigSelection As ShapeRange
    Set OrigSelection = ActiveSelectionRange
    OrigSelection.CreateSelection
    Dim expopt As StructExportOptions
    Set expopt = CreateStructExportOptions
    expopt.UseColorProfile = True
    Dim expflt As ExportFilter

    Dim out_file As String
    out_file = "C:" & Environ("HOMEPATH") & "\export.ai"
    If Len(Dir$(out_file)) > 0 Then
        Kill (out_file)
    End If
    
    ' is an item selected?
    If ActiveSelectionRange.Count > 0 Then
        ' something is selected export it
        Set expflt = ActiveDocument.ExportEx(out_file, cdrAI, cdrSelection, expopt)
        With expflt
            .Version = 10 ' FilterAILib.aiVersionCS6
            .TextAsCurves = True
            .PreserveTransparency = True
            .ConvertSpotColors = True
            .SimulateOutlines = False
            .SimulateFills = False
            .IncludePlacedImages = True
            .IncludePreview = True
            .EmbedColorProfile = True
            .Finish
        End With
    
    Else
        answer = MsgBox("Nothing was selected, Export All?", vbYesNo + vbQuestion, "Export All")
        If answer = vbYes Then
            ' Export everything
            Set expflt = ActiveDocument.ExportEx(out_file, cdrAI, cdrAllPages, expopt)
            With expflt
                .Version = 10 ' FilterAILib.aiVersionCS6
                .TextAsCurves = True
                .PreserveTransparency = True
                .ConvertSpotColors = False
                .SimulateOutlines = False
                .SimulateFills = False
                .IncludePlacedImages = True
                .IncludePreview = True
                .EmbedColorProfile = True
                .Finish
            End With
    
        Else
            'do nothing
            Exit Sub
        End If
    End If
    
    ' Edit this like if lightburn is in a diffrent location
    Call Shell("C:\Program Files\LightBurn\LightBurn.exe " & """" & out_file & """", vbNormalFocus)
    

    End Sub


    when I change the path of the file on the local machine to the psexec command, I get the syyntax error.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.