I have 2 lines which i have to run in cmd everyday multiple times. The lines resemble those below:
set_someclasspaths.bat
java -Xmx1024m foo.bar.stuff.Dashboard -var varone -from 20160701 -to 20160731 -outputdir c:\stuff -ir @ -dashboard
I have thought of two ways to automate this. The first is a batch file and the second is send keys. I have made a file labeled it something.bat and pasted in the above two lines. This quickly opens a window in cmd and closes again (even if i add pause at the end), and doesnt do what i'd expect- infact as far as i can tell it runs the first command then nothing.
The send keys method only seems to run the first line, I have tried:
Sub testcreate()
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1
wsh.Run "cmd.exe /K C:\a\b\set_someclasspaths.bat", windowStyle, waitOnReturn
wsh.sendkeys "java -Xmx1024m foo.bar.stuff.Dashboard -var varone -from 20160701 -to 20160731 -outputdir c:\stuff -ir @ -dashboard"
End Sub
My batch file and java ability are dubious at best, it would seem like the neater way to solve this is the batch file, so i would prefer to do that.
I guess i am passing parameters to a java script in the second line, im not sure if there is syntax for this, and without learning some java and batch file stuff I've ground to a halt.
To clarify, my question is two fold: first is the batch file the better way to do this? Second, why is this not working?
Help greatly appreciated.