echo 当前文件夹 %~dp0 %~dp0new =.\new 当前目录下的new文件夹
echo 参数 %0:当前文件 %1-9: 为执行脚本时的参数
set str=sfaf ss bba
echo 变量 %str% 字符串替换 %str:ss=xx% ,for循环中为 %%var
应用系统升级
1.程序执行下载动作,
2.执行脚本(避免程序执行此步骤 过程中,文件占用,导致失败):关闭执行程序, 替换&备份 升级文件, 执行文件
::echo off
echo ---0.关闭应用
TASKKILL /im TagConfig.exe /t /f
echo ---1.删除上次升级后备份的所有文件(包括子目录)
if exist %~dp0bk del /s/q %~dp0bk
echo -------2.1目录(包含子目录)创建----------------
for /d /r %~dp0new %%f in (*) do call :pathcopy "%%f"
echo -------2.2文件copy,备份源程序&拷贝新程序--------
for /r %~dp0new %%f in (*) do call :filecopy "%%f"
echo ---3.启动应用
start TagConfig.exe
exit
:pathcopy
set path=%1
md %path:new=%
md %path:new=bk%
goto :eof
:filecopy
set file=%1
set runfile= %file:new=%
set bkfile= %file:new=bk%
if exist %runfile% move %runfile% %bkfile%
move %file% %runfile%
GOTO :EOF