'Windows batch file commands not executing

I am trying to run Selenium tests using Docker with Selenium grid for which I am executing a batch file which is present in src\test\resources folder.

Below is the content of the batch file:

cd "%cd%\src\test\resources"
docker-compose -f docker-compose-v3.yml up -d

Below is the Java code in BeforeSuite method:

String gridFilePath = new File(System.getProperty("user.dir") + "\\src\\test\\resources\\start_docker_grid.bat").getAbsolutePath();
System.out.println("absolutePath: " + gridFilePath);
Runtime.getRuntime().exec("cmd /c start \"" + gridFilePath + "\"");

It opens the command prompt window but none of the commands in the batch file are executed.

enter image description here

Can anyone please help here ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source