Lou Pereira
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.Shel l")
objShell.Run strCommand, 0, false
WScript.Sleep 10000
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.Shel
objShell.Run strCommand, 0, false
WScript.Sleep 10000
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello Kimputer,
When I run your suggestion I get the following pop up, see attached.
vbscript-error.png
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"
ASKER
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
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
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.
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.
ASKER
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?
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"
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"
ASKER
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
the E-drive and unc is totally separate not sure I understand. no worries thanks
ASKER
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???
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???
ASKER
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you everyone I was able to get this working via the scheduler instead of running remotely.
ASKER
\\servername\Exports\Trade
c:\area51\remote-execute5.
Thanks for your help!