如何使用SoapUI groovy运行vbs文件

时间:2020-05-29 12:13:31

标签: groovy soapui

我曾经在Java -Eclipse中运行vbs文件

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。.我已经使用groovy在soapui中编写了样本。

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文件时,它正在运行。

0 个答案:

没有答案
相关问题