Link to home
Start Free TrialLog in
Avatar of Lou Pereira
Lou PereiraFlag for United States of America

asked on

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
SOLUTION
Avatar of Tommy Kinard
Tommy Kinard
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lou Pereira

ASKER

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!
Hello Kimputer,
When I run your suggestion I get the following pop up, see attached.
vbscript-error.png
I think that the error is in the space between "EEF Bonds.config"
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
Avatar of Kimputer
Kimputer

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.
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?
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"
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
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???
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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you everyone I was able to get this working via the scheduler instead of running remotely.