I have created a batch file with the following contents
xcopy "C:\Documents\javascript\src\*" "C:\Program Files (x86)\Apache Group\Apache2\htdocs\docs\8.1\version1\" /s /y
I am running the batch file using Java. Running the script from command line or directly executing it(double clicking) doesn't seem to have any problem. However when I run using java the copy operation doesn't succeed. In the console I see a message More? when the script is executed.
Also running the copy operation for directory path without spaces seems to work fine. Here is the java method which does the batch file running.
public void run(String input)
{
File dir = new File(input);
ProcessBuilder processBuilder = new ProcessBuilder("cmd");
processBuilder.redirectInput(dir);
Process process = processBuilder.start();
int exitStatus = process.waitFor();
process.destroy();
}
Any suggestions? Thanks in advance.
It depends on the way you are launching the bat file
for me this works fine:
Runtime.getRuntime().exec("cmd /c start xcopy-file.bat"