title: Running batch file from Java registered as Windows Service using Procrun
body: <p>I have a sample Java application that I registered as a service using <a href="http://commons.apache.org/daemon/procrun.html" rel="nofollow">Procrun</a>. I am trying to execute Batch file from my application</p>
  
  <pre><code>public class Service {
      public static void main(String args[]) throws IOException, InterruptedException {       
          if(args.length&gt;0){
              if(args[0].equals("start")){
                  ProcessBuilder builder = new 
                      ProcessBuilder("cmd","/c","start","Start.bat");
                  builder.start();                
              }else if(args[0].equals("shutdown")){
                  ProcessBuilder builder = new 
                      ProcessBuilder("cmd","/c","start","Stop.bat");
                  builder.start();                    
              }
          }       
      }
  }
  </code></pre>
  
  <p>When I am starting the service, it gets started successfully but it does not launch batch file on my Windows 7.</p>
  
  <p>Contents of Batch files are given below</p>
  
  <p>Start.bat</p>
  
  <pre><code>@echo off
  echo I am started
  pause
  </code></pre>
  
  <p>Please let me know what am I missing here</p>