Skip to main content
Version: current

Execute Windows commands in Katalon Studio

To execute Windows command line, simply use this script in your test case:

String cmd = "Your command"
Runtime.getRuntime().exec(cmd)

Example:

  • Call taskkill command
String cmd = "taskkill /F firefox.exe"
Runtime.getRuntime().exec(cmd)
  • Launch external program:
Runtime.runtime.exec("path/to/vlc.exe")
  • Execute a batch file
import com.kms.katalon.core.configuration.RunConfiguration
/**
* Execute a batch file situated in the KS project directory.
* @param batchFile (String) e.g. "myfile.bat"
*/
static void runBatchFile(String batchFile) {
String bf = RunConfiguration.getProjectDir() + '/' + batchFile
comment("Running batch file: " + bf)
Runtime.runtime.exec(bf)
}

References