Я использовал для запуска файла vbs в Java -Eclipse
myscript.vbs:
Function func
Dim Host
Set Host = CreateObject( "BZWhll.WhllObj" )
ResultCode = Host.Connect( "A" )
If ResultCode <> 0 Then
Host.MsgBox "Error connecting to session A!", 4096
End If
Host.SendKey "A CICSMJ0"
Host.WaitReady 10, 1
Host.SendKey "<ENTER>"
End Function
func
java записанный класс:
public class runvbs {
public static void RunVBs(String jobName) throws InterruptedException, IOException {
// TODO Auto-generated method stub
try {
String currentDir = System.getProperty("user.dir");
//Execute the vbscript name which is passed in this method.
//Generally it is runmfjob.vbs is the vbscript to run as a pre-requisite.
Runtime.getRuntime().exec("wscript " + currentDir + "\\vbscript\\" + jobName + ".vbs");
boolean statusofjob;
//Every 60 seconds monitor the jobs and print the job is completed or not.
//Do loop executes until the job is completed.
do {
System.out.println("Mainframe Job is running and waiting to complete it");
Thread.sleep(60000);
} while (DataGenerator.getstatusofJob() == true);
System.out.println("Vbscript is completed");
} catch (InterruptedException e) {
System.out.println(e);
System.exit(0);
}
}
}
То же самое нужно преобразовать в groovy .. Я написал как образец в soapui, используя groovy.
import java .io.IOException;
try {
Runtime.getRuntime().exec("wscript.exe C:\\Users\\3020722\\Desktop\\Navigator\\myScript.vbs");
} catch (Exception ex) {
log.info(ex)
ex.printStackTrace();
}
Я получаю ActiveX component can't create object 'BZWhll.Whllobj'
Если я даю Dim Host As Object
и бегу показывает, что это expecting end of statement
в этой строке ..
Когда я запускаю файл vbs напрямую, он запускается.