0

I need to execute this command to stop selenium server.

wmic path win32_process Where "CommandLine Like '%selenium-server%'"  Call Terminate

from my java program. I tried

Runtime.getRuntime().exec("command as a single string escaped")

and

Runtime.getRuntime().exec(String[])

but it is not getting executed. When I execute the same command from cmd it is working fine. Can someone please help.

2 Answers 2

1

Escaping/handling white spaces are better run done with ProcessBuilder.

Sign up to request clarification or add additional context in comments.

Comments

0

You can try to use this one:

public Process exec(String[] cmdarray, String[] envp, File dir) 
  throws IOException   

Executes the specified command and arguments in a separate process with the specified environment and working directory.

then wait for the process to end using the process.waitFor() methode.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.