<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    The problem with launching the batch file turned out to be that
    Windows doesn't natively know how to launch batch files. The
    operating system doesn't know what to make of "FEA.bat", but "cmd /c
    FEA.bat" works. (I.e., launching a batch file is an option of the
    "cmd" command.) I am still not sure why the method I first tried,
    directly sending "getdp -pre EleSta_v.pro -cal", didn't work. I may
    investigate at some point, but doing it via batch file is an
    acceptable work-around. Thanks to all who helped: Joris, Lars, and
    Ruth.<br>
    <br>
    John<br>
    <br>
    <br>
    On 12/1/2010 2:48 PM, Joris Goethals wrote:
    <blockquote
      cite="mid:AANLkTikUpVFW=jHpKfGx=x_ADc-hxYm17RxasUj3NtOi@mail.gmail.com"
      type="cite">Hi there,
      <div><br>
        <div>In my program, I used this code to launch GetDP:</div>
        <div>First I used an array of command and parameters, but that
          gave me the same CreateProcess error.</div>
        <div>Now I put every command in a String.format(), and execute
          it with the following method:</div>
        <div><br>
        </div>
        <blockquote class="webkit-indent-blockquote" style="margin: 0pt
          0pt 0pt 40px; border: medium none; padding: 0px;">
          <div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>private void executeCommand(String cmd) {</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>try {</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>if(cmd ==null){</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>notifyListeners("Kan het commando niet uitvoeren",
              ERROR);</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>}</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>Runtime rt = Runtime.getRuntime();</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>if (workDir == null) {</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>notifyListeners("De werkmap is nog niet
              ingesteld", Infobalie.ERROR);</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>throw new NullPointerException("Werkmap nog niet
              ingesteld");</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>}</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>System.out.printf("Uitvoeren van commando %s\n",
              cmd);</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>Process p = rt.exec(cmd, null, workDir);</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>InputStream std = p.getInputStream();</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>InputStreamReader isr = new InputStreamReader(std);</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>BufferedReader br = new BufferedReader(isr);</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>String line = null;</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>while ((line = br.readLine()) != null){</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>notifyListeners(line,
              (line.startsWith("Warning")?ERROR:NEUTRAAL));</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>}</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>int exitvalue = p.waitFor();</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>notifyListeners(String.format(</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>"Commando uitgevoerd met exitwaarde %d.",
              exitvalue),</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>Infobalie.SUCCESS);</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>} catch (IOException ioe) {</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>System.out.println(ioe.getMessage());</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>ioe.printStackTrace();</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>} catch (Exception e) {</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>e.printStackTrace();</div>
            <div><span class="Apple-tab-span" style="white-space: pre;">
              </span>}</div>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
        </blockquote>
        This method is called by </div>
      <blockquote class="webkit-indent-blockquote" style="margin: 0pt
        0pt 0pt 40px; border: medium none; padding: 0px;">
        <div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>public
            void pre(int pre) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>String
            command = null;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>try
            {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>command
            = String.format("%s %s -msh %s -pre %s",</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>getDpExe.getPath(),
            problemDefinition.getPath(), geo.getPath(),
            resolutieLijst.get(pre));</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            catch (NullPointerException npe) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>notifyListeners("Niet
            genoeg parameters om commando uit te voeren",</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>ERROR);</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>return;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>executeCommand(command);</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
        </div>
      </blockquote>
      <blockquote class="webkit-indent-blockquote" style="margin: 0pt
        0pt 0pt 40px; border: medium none; padding: 0px;">
        <blockquote class="webkit-indent-blockquote" style="margin: 0pt
          0pt 0pt 40px; border: medium none; padding: 0px;">
          <div>
            <div>public void cal() {</div>
          </div>
        </blockquote>
      </blockquote>
      <blockquote class="webkit-indent-blockquote" style="margin: 0pt
        0pt 0pt 40px; border: medium none; padding: 0px;">
        <div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>String
            command = null;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>try
            {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>command
            = String.format("%s %s -msh %s -cal",</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>getDpExe.getPath(),
            problemDefinition.getPath(), geo.getPath());</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            catch (NullPointerException npe) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>notifyListeners("Niet
            genoeg parameters om commando uit te voeren",</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>ERROR);</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>return;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>executeCommand(command);</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
        </div>
        <div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>public
            void pos(int post) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>String
            command = null;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>try
            {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>command
            = String.format("%s %s -msh %s -pos %s",</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>getDpExe.getPath(),
            problemDefinition.getPath(), geo.getPath(),</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>postCalculationLijst.get(post));</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            catch (NullPointerException npe) {</div>
          <div>
            <span class="Apple-tab-span" style="white-space: pre;"> </span>notifyListeners("Niet
            genoeg parameters om commando uit te voeren",</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>ERROR);</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>return;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>executeCommand(command);</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
        </div>
      </blockquote>
      <br>
      <div>Good luck with it!</div>
      <div>Joris</div>
    </blockquote>
  </body>
</html>