title: return a value from .bat file to the calling application
body: <p>I am using the below code to execute the .bat file and read the response.</p>
  
  <pre><code>java.lang.ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/C", "C:\\main.bat");
      java.lang.Process p = pb.start();            
      String line;
      BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
      while ((line = r.readLine()) != null) {
          System.out.println(line); &lt;--this works
      }
      r.close();
  }
  }
  </code></pre>
  
  <p>The main.bat will just echo the value</p>
  
  <pre><code>call sample.bat c:\sample.txt value1
  echo %value1% &lt;---this works
  </code></pre>
  
  <p>However now I want to pass a parameter from the java code that will be set in the batch file and can be printed in the java code.     </p>
  
  <pre><code>java.lang.ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/C", "C:\\main.bat" +s1);
  java.lang.Process p = pb.start(); 
  System.out.println(s1); &lt;--- this does not work
  </code></pre>
  
  <p>Can someone please let me know how to return a value from .bat file to any calling application?</p>