VBScript run a remote executable

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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tommy KinardCommented:
Appears on the surface to have too many ".

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

Open in new window

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!
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Lou PereiraAuthor Commented:
Hello Kimputer,
When I run your suggestion I get the following pop up, see attached.
Tommy KinardCommented:
I think that the error is in the space between "EEF Bonds.config"
Lou PereiraAuthor Commented:
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.
strCommand = """\\" & strComputer & "\Exports\Trade Export.exe""" & " -x " & """\\" & strComputer & "\Exports\BNY\EEF Bonds.config"""

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
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.
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?
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?
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"
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
Lou PereiraAuthor Commented:
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???
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
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lou PereiraAuthor Commented:
Thank you everyone I was able to get this working via the scheduler instead of running remotely.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.