最近有个需求,需要在windows 下开机自动启动项目并全屏打开浏览器进入指定网页。
编写脚本如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
@echo off @echo 启动tomcat start D:\apache-tomcat-7.0.70\bin\startup.bat setlocal enabledelayedexpansion :1 netstat -an|findstr 8080 >nul if errorlevel 1 ( echo 端口未开启 ping /n 10 127.1 >nul goto 1 ) else ( echo 端口已开启 start iexplore.exe -k "http://localhost:8080/lfiom-morgan/html/morgan.html" exit ) |
逻辑为:
首先启动tomcat服务器,即打开应用
然后每隔10秒轮询查看8080端口是否开启。判断应用是否启动
当应用开启后启动ie浏览器,-k是全屏打开指定页面。然后退出
将这个脚本放入windows开机启动项里面即可
如果是谷歌浏览器,则是:
1 |
tasklist|findstr /i "chrome.exe" ||start chrome.exe -kiosk "http://localhost:8080/lfiom-morgan/html/morgan.html" |