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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.