VBScript run a remote executable

Hello,
I am having a problem running the following script where it keeps failing with the strCommand not being valid see below:
strCommand = ("\\" & strComputer & ""\Exports\Trade Export.exe -x"" & " " & "\\" & strComputer & ""\Exports\BNY\EEF Bonds.config"")

Here's the entire script:
Option Explicit
Dim strComputer
Dim strCommand,objShell
Dim server
Dim objShell2
Dim strping
Dim wshShell
Dim mycommand
Dim objFSO

strComputer = "servername"
'strComputer = InputBox ("Please specify the computer name to be shutdown without the leading backslashes.","Computer Name")

strCommand = ("\\" & strComputer & ""\Exports\Trade Export.exe -x"" & " " & "\\" & strComputer & ""\Exports\BNY\EEF Bonds.config"")
 WScript.echo strCommand
'strCommand = "shutdown.exe -r -f -t 3 -m \\" & strComputer
set objShell = CreateObject("WScript.Shell")
objShell.Run strCommand, 0, false

WScript.Sleep 10000
Lou PereiraAsked:
Who is Participating?
 
Tommy KinardCommented:
Try this
 """\\" & strComputer & "\Exports\BNY\Trade Export.exe""" & " -x " & """\\" & strComputer & "\Exports\BNY\EEF Bonds.config"""

I will have to bow out as I have no servers to test halcyon software  on.
0
 
Tommy KinardCommented:
Appears on the surface to have too many ".

strCommand = ("\\" & strComputer & "\Exports\Trade Export.exe -x" & " " & "\\" & strComputer & "\Exports\BNY\EEF Bonds.config")
0
 
KimputerCommented:
strCommand = """\\" & strComputer & "\Exports\Trade Export.exe""" & " -x " & """\\" & strComputer & "\Exports\BNY\EEF Bonds.config"""

Open in new window

0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Lou PereiraAuthor Commented:
When I run with your parameters I get the following:
\\servername\Exports\Trade Export.exe -x \\NYVMHALCYONS1\Exports\BNY\EEF Bonds.config
c:\area51\remote-execute5.vbs(35, 1) (null): The system cannot find the file specified.

Thanks for your help!
0
 
Lou PereiraAuthor Commented:
Hello Kimputer,
When I run your suggestion I get the following pop up, see attached.
vbscript-error.png
0
 
Tommy KinardCommented:
I think that the error is in the space between "EEF Bonds.config"
0
 
Lou PereiraAuthor Commented:
Tommy/Kimputer,
I was able to run the script with "%comspec% /k" in the run statement, but it does not seem to run successfully because it does not create a log.
String:
strCommand = """\\" & strComputer & "\Exports\Trade Export.exe""" & " -x " & """\\" & strComputer & "\Exports\BNY\EEF Bonds.config"""

RUN:
objShell.Run "%comspec% /k" & strCommand, 0, false

Note if I run from the server from a command prompt it works.  See below
E:\Exports\BNY>"Trade Export.exe" -x "EEF Bonds.config"
Initializing the company Trade Export Application
Running in Production Mode

Thank you for all your help
0
 
KimputerCommented:
In your screenshot, Trade Export has been started, but probably can't handle the networking issue.
Are you sure Trade Export is able to handle the networking issue (including the remote file). Otherwise copy the file to your PC first, and run the command with that file as an argument.
0
 
Lou PereiraAuthor Commented:
you suggestion doesn't work either, it produces same results, it looks like it ran, but no log is created.
Any suggestion on my least message?
0
 
Tommy KinardCommented:
What I am not getting is you are using "\\" in your example but on the comspec you are using "E:". Also there is no BNY in the string for strCommand. The only reason I am saying anything is \\ is a server E: is a mapped drive, \\E: does not work. :) So where do we start at now?
0
 
KimputerCommented:
It looks like your program cannot handle the networking part. Therefore you should fall back to psexec (from MS Technet PSTOOLS suite).
Something like on the command prompt (only if it works we can continue with the VBscript):

psexec \\strComputer "E:\Exports\BNY\Trade Export.exe" -x "E:\Exports\BNY\EEF Bonds.config"
0
 
Lou PereiraAuthor Commented:
Tommy I think you're a bit confused, as I explained running from the server itself it works, I figure to at least test that aspect.
the E-drive and unc is totally separate not sure I understand. no worries thanks
0
 
Lou PereiraAuthor Commented:
Kimputer,
I did try psexec and did not work either! The exe's have names with spaces which I never liked to begin with, furthermore it echos to screen when running from command prompt.  One of the guys here explained when it runs locally from the task scheduler it works fine as well.

I also tested the powershell invoke command to no avail???
0
 
Lou PereiraAuthor Commented:
Would one of you be so kind to double check the following and advise why it's not working:
objShell.run "cmd.exe /C SCHTASKS "" /Run /S nyvmhalcyons1 /U halcyon\hamtasksch /P H@lcy0n2015! /I /TN \Exports\Bank of New York (EEF) Bond Export"""

Thank you very much
0
 
Lou PereiraAuthor Commented:
Thank you everyone I was able to get this working via the scheduler instead of running remotely.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.