title: Batch/cmd: stop glassfish, copy file, start glassfish
body: <p>My objective is fairly simple. I have a glassfish server. I made a change to the jar which I need to put into the domains/lib folder. For that I have to stop-domain, copy the file over, then start domain. I thought using batch file would be a fairly efficient way to do that; however, I seem to be struggling.</p>
  
  <p>Here is what I've got </p>
  
  <pre><code>REM ##### Set paths #####
  SET glassfish_home=C:\glassfish-4.1\bin
  SET target_folder=C:\dummypath\target
  SET domain_lib=C:\glassfish-4.1\glassfish\domains\domain1\lib
  SET jar=dummyfile.jar
  PAUSE
  
  REM ##### Stop glassfish server #####
  cd %glassfish_home%
  asadmin stop-domain
  
  REM ##### Copy DataAccess jar #####
  cd %target_folder%
  COPY %jar% %domain_lib%\
  
  REM ##### Start glassfish server #####
  cd %glassfish_home%
  asadmin start-domain
  </code></pre>
  
  <p>However, what is happening right now is it seems to stop the domain, but does not proceed to do anything else. Definitely doesn't start it again.</p>
  
  <p>I've attempted to comment out stop-domain and just manually stopped it. I then ran the batch file and it copied the file, started the domain, but it did not close and remained on the cmd screen with "Command start-domain executed successfully." message.</p>
  
  <p>Any insight into why my batch file doesn't all run smoothly, is greatly appreciated!</p>