I am trying to run command line from java. From java, the code should open a new cmd, change to specific dir (C:\EasyTest\4\bin) and run command (runTC 'testCase/test2.tc -c love -k ShinRamyun -logToConsole') from there. To do so, I tried several ways but not working.
String[] command = {"CMD", "/C", "start", "runTC","testCase/test2.tc -c love -k ShinRamyun -logToConsole"};
ProcessBuilder probuilder = new ProcessBuilder( command );
probuilder.directory(new File("C:\\EasyTest\\4\\bin"));
Process process = probuilder.start();
it returns opened cmd for 1 sec and exits directly. I couldn't see the result and the application which is executed by runTC is not affected.
the other way, I run
ProcessBuilder processBuilder = new ProcessBuilder( "cmd", "/c","start", "cd C:\\EasyTest\\4\\bin && runTC testCase/test2.tc -c love -k ShinRamyun -logToConsole\"" );
processBuilder.start();
But it only launches cmd with title 'cd C:\EasyTest\4\bin && runTC testCase/test2.tc -c love -k ShinRamyun -logToConsole\' and dir of the project related
What I want is run 'runTC testCase/test2.tc -c love -k ShinRamyun -logToConsole' from specific dir from cmd
Any suggestion?