开发者

run command after jetty starts in batch

开发者 https://www.devze.com 2023-01-11 02:07 出处:网络
Ok, here\'s the problem. My goal is to run FF Portable, when Jetty starts. My start.bat looks like that:

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 c开发者_运维技巧losed?
  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.


For your first question, try this:

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


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.
0

精彩评论

暂无评论...
验证码 换一张
取 消