1. 目录相关
~dp0:执行文件当前目录
cd: 当前工作目录
pushd %cur_dir% 设置当前工作目录为cur_dir 变量指向的目录
2. 判断某个字段是否在某个文件中
findstr /r "FAILED" log.make.log >NUL 2>NUL
3.pause 暂停执行,在退出bat之前可以用它来查看bat执行过程
样例如下:
@echo off
set cur_dir=%~dp0
set work_dir=%cd%
pushd %cur_dir%
findstr /r "FAILED" log.make.log >NUL 2>NUL
IF ERRORLEVEL 1 goto success
IF ERRORLEVEL 0 goto failure
:success
echo "SUCCESS"
exit /b 0
:failure
echo "FAILURE"
exit /b 1