windows更新包脚本的记录

 

setlocal EnableDelayedExpansion
cd /d  %~dp0
rem **************** (0) up to admin   
PUSHD %~DP0 & cd /d "%~dp0"
%1 %2
mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :target","","runas",1)(window.close)&goto :eof
:target
  
rem **************** (1) get install_dir

for /f "tokens=3"  %%i in ('reg query " HKEY_CLASSES_ROOT\meshview" /v "install_dir" ') do (
 set install_dir=%%i
)
echo %install_dir%
echo %install_dir%\meshview
rem **************** (2) read config  get old date ; read application read new date

CALL :readconfig ./application.yml version myversion 
 echo "now is %myversion%"
 set newversion=%myversion% 
CALL :readconfig %install_dir%/meshview/config/application.yml version myversion 
 echo "now is %myversion%"
 set oldversion=%myversion% 

rem **************** (3) update mysql 
set olddate=%oldversion:~-8%
set newdate=%newversion:~-8%
echo %olddate%
echo %newdate%
call :sqlhandle %olddate%  %newdate%

%install_dir%\mysql-5.7.27-winx64\bin\mysql.exe -uroot -p123456 -s -f mesh < ./updatesql.txt 2 >> update.log

rem ****************(4) stop app; update app and static html ;
taskkill /f /im javaw.exe

xcopy /Y app\mesh-nmp.jar %install_dir%\meshview\mesh-nmp.jar

xcopy nginx\dist\* %install_dir%\meshview\static\ /s/e/i/y
pause

rem ****************(5) refresh config  start app 
call ./updateContent.bat %install_dir%\meshview\config\application.yml %oldversion%  %newversion%

taskkill /f /im javaw.exe

@echo on
cd /d %install_dir%\meshview
echo %install_dir%\meshview

start "mesh-view" javaw -jar "./mesh-nmp.jar"

rem ============================+++readfile==============================
:readconfig
@echo off
for /f "tokens=1,2   delims=:" %%a IN ( %1 )  Do  (
rem echo %%a
set tt=%%a
rem echo !tt!
CALL:intercept_all tt
if !tt!==%2 ( echo %%a & set %3=%%b && echo !%3! ) 
)
goto:eof

:intercept_all
	set "str=   ab c&>!   " 
	setlocal
		set "str=!%1%!"
		set "str=%str: =%"
		(endlocal
			set "%1=%str%"
		)
goto:eof
rem ============================readfile+++==============================
rem ============================+++sqlhandler==============================
:sqlhandle
@echo off
for /L %%a in (%1 1 %2) do (
 rem echo %%a 
 if exist update/%%a  (
  echo %%a is a dictory   
   for /r %%i in ( .\update\%%a\*.sql ) do (
     echo %%i
     type %%i >> updatesql.txt
     )
  ) else  (
   echo ./update/%%a is not exists
   )
 )
goto:eof
rem ============================sqlhandler+++==============================
pause

读文件及组合出增量文件的函数如下。

注意区分 call *.bat function 是可以回来 的

goto function 

./*.bat 都是回不到本脚本文件环境的。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dualven_in_csdn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值