PDA

View Full Version : [SOLVED] Run JavaScript and Get Return



cmccabe1
11-30-2015, 11:39 AM
I am trying to call the command prompt, execute a java script and have a message displayed upon completion.
However I am getting a


Method 'Run' of Object 'IWshShell3' failed
I can not seem to fix it. Thank you :).




MsgBox ("ImaGene running, please wait")


Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1




wsh.Run "C:\Program Files\BioDiscovery\ImaGene 9.0\ImaGene.exe"" batch " _
& XML-*File*-Name, windowStyle, waitOnReturn
MsgBox ("ImaGene completed")

I have also tried:



Shell "C:\Program Files\BioDiscovery\ImaGene 9.0\ImaGene.exe -batch ""C:\Users\cmccabe\Desktop\EmArray\Design\imagene.bch"" /A" and that seems to execute the command but there are no results

Kenneth Hobs
11-30-2015, 03:16 PM
Seems like you asked this on this forum or another.

Try to put your string to Run in a variable first. Obviously, your wsh string to run is not the same as the shell string.

This puts the value of s into the Immediate Window after a run. There are other shellandwait routines but the wsh method should work for you once you get the string to work right. To know if you got it right, after a run, copy that string in the Immediate Window, and then paste it to the Win+R window.


Sub ken() Dim s As String
s = "C:\Program Files\BioDiscovery\ImaGene 9.0\ImaGene.exe -batch ""C:\Users\cmccabe\Desktop\EmArray\Design\imagene.bch"" /A"
Debug.Print s
Shell s, vbNormalFocus
DoEvents
MsgBox "done"
End Sub

cmccabe1
01-26-2016, 01:47 PM
Thank you :).