How to execute VBS script in Java? What is he preferred way? I found in Internet so many advices, so I don't know what is better...
1.
Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
2.
Runtime.getRuntime().exec("wscript.exe " + file.getPath())
3.
String script = "C:\\work\\selenium\\chrome\\test.vbs";
String executable = "C:\\windows\\...\\vbs.exe";
String cmdArr [] = {executable, script};
Runtime.getRuntime ().exec (cmdArr);
4.
Runtime.getRuntime().exec("cmd /c a.vbs");
5.
Desktop#open(new File("c:/a.vbs"));
And It is not all.
What kind of this to choose? I need to execute following script:
If Not IsObject(application) Then
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"