views:

36

answers:

1

I am writing a windows batch file to do the following things:

  1. Display a picture in the middle of the screen, showing the beautiful icon of my software.
  2. Kick of the launch of the web server.
  3. Finish displaying the picture.
  4. Point the browser to the start page.

I have already know how to do it in step 2 and 4. However, I have the following questions in writing the windows batch file: 1. How do I know that the launch of the web server is finished, taking jetty as the example? 2. How do I display a picture and stop displaying it when I want to?

Here is what I have got so far:

::here I would like to display the picture
start javaw -jar start.jar ::Starting jetty here
::here I would like to stop displaying the picture
start http://localhost:8080/myApp ::Pointing the browser to the page

Thank you in advance for your help.

+1  A: 

I don't know how well you know batch fiels, but if it's a closer match to your skill set, it might be easiest that you write a small java program to repeatedly poll the port of the webserver until you can make a connection. You can then invoke that program from the batch file - use call rather than start, so that the batch waits until your polling program has finished.

If you want to implement using just batch commands, you can use the [NETSTAT][1] command to write a list of ports being listened on to a file. Use FIND to search the file to see if your web server port is in the list. If the port is not found, repeat.

Parsing the output of netstat might be tricky. another approach is to use 'wget' to fetch a webpage from the local server. Repeatedly invoke wget (with pauses in-between) until ERRORLEVEL indicates success.

mdma
Thank you. It's a great answer.
Winston Chen