views:

41

answers:

3

Ok, here's the problem.

My goal is to run FF Portable, when Jetty starts. My start.bat looks like that:

@echo off
start /B start_jetty.bat 
start /B start_firefox.bat 

start_jetty.bat:

@echo off
cd jetty-7.1.6/
java -jar start.jar 

start_firefox.bat:

@echo off
ping -n 1 -w 6000 0.0.0.1
"%cd%\FirefoxPortable\FirefoxPortable.exe" 

Questions:

  1. How can i make start_firefox.bat to execute after jetty starts?
  2. DONE - How can i run both of those batch without any console?
  3. How can i stop jetty after firefox is closed?
  4. Is there any way i could make it cleaner and safer?

edit: /B as start command option eliminates additional console windows. edit2: trick in firefox start, now it waits for 6 seconds before it starts.

A: 

Try to delete System32 folder. It should do the trick

Ammian
A: 

For your first question, try this:

@echo off
  CALL start /B start_jetty.bat 
  CALL start /B start_firefox.bat 
aphoria
When i tried this code i got stuck in infinitive loop...
tzim
Well i wasn't infinitive ;)
tzim
A: 

So my solution looks like that:

start.bat:

@echo off
REM is there java in system!
cls
setlocal ENABLEEXTENSIONS
set KEY_NAME="HKLM\SOFTWARE\JavaSoft\Java Runtime Environment"
set VALUE_NAME=CurrentVersion
FOR /F "usebackq skip=4 tokens=3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`)    DO (
    set ValueValue=%%A
)

if defined ValueValue (
    goto java_ok
) else (
    goto java_not_ok
)

:java_not_ok
REM there's no java 
msg * "There is no java in your system!"
goto:EOF

:java_ok
REM there is java
start /B start_jetty.bat 
start /B start_firefox.bat 
goto:EOF

start_jetty.bat

@echo off
cd jetty-7.1.6/
java -DSTOP.PORT=8087 -DSTOP.KEY=stopme  -jar start.jar

start_firefox.bat

@echo off
ping -n 1 -w 6000 0.0.0.1
"%cd%\GoogleChromePortable\GoogleChromePortable.exe"
cd jetty-7.1.6/
java -DSTOP.PORT=8087 -DSTOP.KEY=stopme  -jar start.jar --stop

Yes i know that start firefox is actually start chrome, but!.

  1. FirefoxPortable wont start if there is another firefox in use.
  2. If i decide to set FFPortable to multiinstance, instructions in start_firefox.bat executes immediate after FFP is on. Not after it's close.
tzim