When you drag an application .EXE from the Files explorer to the main test script window (MyTest.js), Rapise automatically adds the following code:


This works well for executables, but for Windows Batch files (ones ending in .BAT), you need to use a different syntax, as shown below:

  var wsh = new ActiveXObject("WScript.Shell");

This call will launch a batch file and return without waiting for it to finish. If you need to run in synchronously then you need to add a couple of parameters to the call:

  var wsh = new ActiveXObject("WScript.Shell");
  var errCode = wsh.Run("C:/Temp/test.bat", 2, true);

You may see, that we can get process error code in this case.

Please, note. If path to a test file contains space, then full path to your batch file should be enclosed in double quotes like that:

  var wsh = new ActiveXObject("WScript.Shell");
  var errCode = wsh.Run('"C:/Path with Spaces/test.bat"', 2, true);

Also note, that if you refer to the path using %WORKDIR% and it may contain a path then it is saver to use a quote:

  var wsh = new ActiveXObject("WScript.Shell");
  var errCode = wsh.Run('"%WORKDIR%/test.bat"', 2, true);

By default WORKDIR points to the folder of the parent test. So if BAT file you launch is inside the test folder you can omit %WORKDIR%.