I need to change the working directory first. Then run my batch file with some parameters located in .txt file. I searched to open a batch file, though it works I am unable to change working directory and then run it and to pass parameters too.
Java Snippet:
final String dosCommand = "cmd /c start cmd.exe /K";
final String location = "\"C:/Program Files/.../abc.bat";
final String trail = "d:\\xyz.txt";
try {
final Process process = Runtime.getRuntime().exec(
dosCommand + " " + location + " " + "pro_wait" + " " + trail);
final InputStream in = process.getInputStream();
int ch;
while((ch = in.read()) != -1) {
System.out.print((char)ch);
}
} catch (IOException e) {
e.printStackTrace();
}
On command prompt I am executing command as,
D:\>"C:\Program Files\...\abc.bat" pro_wait d:\xyz.txt
I am unable to execute complete command from JAVA. Please help. Thanks in advance to all!