赞
踩
要点:
1.后台运行
2.相对路径
3.可重复执行
例1:
nginx启动:
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
tasklist | find /i "nginx.exe" >nul 2>nul && goto jump || goto start
:start
cd ./nginx &&start nginx
:jump
echo qidongzhong
例2:
minio启动:
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
tasklist | find /i "minio.exe" >nul 2>nul && goto jump || goto start
:start
cd ./minio &&minio server cd ./minio
:jump
echo starting
例:
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
set port=80
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
echo kill the process %%m who use the port
taskkill /pid %%m -t -f
goto start
)
:start
cd ./ &&chcp 65001&&java -Dfile.encoding=utf-8 -jar EquipManagePlat.jar
要点:
1.后台运行
2.相对路径
3.批量运行
例:
set ws=createobject("wscript.shell")
currentpath = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
ws.run currentpath+"/minio.bat",0
ws.run currentpath+"/nginx.bat",0
ws.run currentpath+"/mqtt.bat",0
ws.run currentpath+"/HikDevServer.bat",0
ws.run currentpath+"/DahDevServer.bat",0
ws.run currentpath+"/EquipManagePlat.bat",0
//延迟8s
WScript.sleep 8000
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。