command[0] = "cmd";
command[1] = "/C";
command[2] = "dir";
command[3] = "C:\\SomeDir";
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(command , null , workDir);

It is working fine. Here the executable command is "dir". Here p.waitFor() gives value 0.
But if I give any other command suppose "rename *.doc *.rtf"
Here p.waitFor() gives value 1.
It is not working. and no error is coming.

Actually my require is to run our user definnd command from java program. And that command is working properly from command prompt.

8 Years
Discussion Span
Last Post by verruckt24

waitFor returns an exitValue in int. If this value is zero it specifies normal termination. Any other value specifies an abnormal termination, so this means that the process is running to completion, but not with desired results. Since you are claiming to renam files over here, just whether you have permission to.
Also go through this link, you may find it of interest.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.