I am trying to run batch file using java command. I have following code
Runtime.getRuntime().exec("cmd /c start C:\\temp\\Sept_2016\\22Sept\\filecompare.bat");
I have batch file named filecompare.bat as below
fc "C:\temp\Sept_2016\22Sept\MSP_Files\msp.txt" "C:\temp\Sept_2016\22Sept\MIB_Files\mib.txt">>"C:\temp\Sept_2016\22Sept\mismatch.txt"
This works as per expected and output gets stored in txt file.
Now I don't want to use hard coded values as above I want to get the values from Java program. So I am writing java code as below
String file1 = new String("C:\\temp\\Sept_2016\\22Sept\\MSP_Files\\msp.txt");
String file2 = new String("C:\\temp\\Sept_2016\\22Sept\\MIB_Files\\mib.txt");
String file3 = new String("C:\\temp\\Sept_2016\\22Sept\\mismatch.txt");
Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c", "start C:\\temp\\Sept_2016\\22Sept\\filecompare.bat", file1, file2, file3});
On the similar lines I am modifying batch file as
fc %4 %5>>%6
But this does not seem to be working. It is just opening dos window.
Could you please help me achieve this? Thanks in advance
%4,%5and%6?startandC:\\temp\\Sept_2016\\22Sept\\filecompare.bat. Anywaystartis not needed you can remove it.cmdbut when it invokesfilecompare.batit pass only 3 parameters there.filecompare.batknow nothing about those 5 parameters. It knows only about parameters that was passed to it.