MS-DOS Batch Script Template
@echo off
@setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION @rem Name:
@rem Purpose:
@rem
@rem Author:
@rem Revision:
@rem @rem @echo off
@rem @set method=goto:eof
@rem @set mbegin=setlocal
@rem @set mend=endlocal^&goto:eof @rem ^& call :quit ^%errorlevel^%
@set method=@goto:eof
@set mbegin=@set a1xyzefwew=""
@set mend=@goto:eof
@set mreturn=@exit /b !errorlevel!
@set return=@goto :on_exit @set errorlevel=0 @rem go to rum main()
@goto :main %method%
: usage ()
%mbegin% echo %~1% %mend% %method%
: config ()
%mbegin% set me=%~n0
set mex=%~nx0 @rem
@rem initialize configuration items here
@rem
set HEAD_LINE=***************** call :parse_commind_line %* %mend% %method%
: main ()
%mbegin% @rem Check if need to show help informaiton
if "%~1" neq "" (
set param1=%~1
if "!param1:/?=!" neq "!param1!" (
call :usage %~nx0
exit /b 1
)
) @rem load configuration
call :config %* @rem initilize log environment
call :init_log @rem log example
@rem set log=C:\windows\system32\inetsrv\appcmd.exe set config "UimDirectAuxTestWebSite" /section:UimDirectAuxModule/"+references.[name='JOSE-JWWD_Server\AuthenFilter\uim-direct-aux\UimDirectAuxWebTest\uim_direct_aux\bin\jose-jwt.dll']"
@rem call :tee "%log%" @rem
@rem add business logical here
@rem @rem for example, call a method
@rem call :method1 || ( set errorlevel=1 & %return%) %return% %mend% %method%
: method1 ()
%mbegin% @rem mkdir foldername >nul || (set errorlevel=1 & %mreturn%) @rem set errorlevel=0 & %mreturn% %mend% %method%
: parse_commind_line ()
%mbegin%
:lbl_param_list
shift /1
if "%1" equ "" (
goto:eof
) @rem read optional args
@REM set p=%~1
@REM set p2=%p:/old_filter=%
@REM if /i "%p%" neq "%p2%" (
@REM if /i "%~2" neq "" (
@REM set g_optional_param_name=%~2
@REM )
@REM )
goto :lbl_param_list %mend% %method%
: print_head ()
%mbegin%
@call :log_prefix
@echo %LOG_PREFIX% %HEAD_LINE% %mex% log %HEAD_LINE% > %log_file%
%end% %method%
: print_foot ()
%mbegin%
@call :log_prefix
@echo %LOG_PREFIX% %HEAD_LINE% %mex% log %HEAD_LINE% >> %log_file%
%end% %method%
: init_log ()
%mbegin%
@rem get log file name
set log_file=%LOCALAPPDATA%\%me%\log
if not exist %log_file% (
mkdir %log_file% || echo "failed to create %log_file% with error %errorlevel%" & got :eof
)
set log_file="%log_file%\%mex%.log" @rem initialize the log file
call :print_head
%mend% %method%
@rem
@rem output message to both stdout and %log_file%
@rem
: tee ()
@rem
@rem %* -- message
@rem
%mbegin%
@call :log_prefix
@set tee_log=%* @rem remove left "
set left_char=%tee_log:~0,1%
set left_char=%left_char:"=%
if "%left_char%" equ "" (
set tee_log=%tee_log:~1%
)
@rem remove right "
set right_char=%tee_log:~-1,1%
set right_char=%right_char:"=%
if "%right_char%" equ "" (
set tee_log=%tee_log:~0,-1%
) @set tee_log=%LOG_PREFIX% %tee_log%
echo %tee_log%
@echo %tee_log% >> %log_file%
%mend% %method%
: log_prefix
%mbegin%
@set LOG_PREFIX=[%date:~0,-4% %time%]
%mend% %method%
@rem
@rem exit the batch with checking the error code
@rem please use this method by "goto :on_exit" rather than "call :on_exit"
@rem
: on_exit ()
%mbegin%
if %errorlevel% neq 0 (
echo %LOG_PREFIX% Failed to execute %mex%. For more information, please %log_file%
) else (
echo %LOG_PREFIX% Succeeded in executing %mex%. For details, please %log_file%
)
call :print_foot
@rem type %log_file%
endlocal
exit /b %errorlevel%
%mend%
MS-DOS Batch Script Template的更多相关文章
- Use windows batch script to create menu
Background Recently, I find that we need to type some very long gradle commands to run build, chec ...
- 今天再给大家带点html5前端开发的干货模板“text/tpl”怎么用 script template怎么用
text/tpl 顾名思义就是模板,其实和C++模板函数类似的作用,就是利用他生成一个HMTL内容,然后append或者替换html里面 有什么好处,假如后端返回来的数据都是一样的,但是需要生成不同的 ...
- 小白学习vue第五天-第二弹(全局局部、父子、注册语法糖,script/template抽离模板)
全局组件: 就是注册的位置在实例对象的外面 并且可以多个实例对象使用 而局部: 就是在实例对象的内部注册 父组件和子组件的关系 子组件就是在另一个组件里面注册的组件 组件注册语法糖: 就不用Vue.e ...
- MS DOS 命令大全
刚好看到留下来以备用: 一)MD——建立子目录命令 1.功能:创建新的子目录 2.类型:内部命令 3.格式:MD[盘符:][路径名]〈子目录名〉 4.使用说明: (1)“盘符”:指定要建立子目录的磁盘 ...
- 在Virtual Box虚拟机中安装MS DOS!
原文地址:https://mylinuxramblings.wordpress.com/2010/12/05/linux-mint-debian-edition-lmde-first-impressi ...
- MS dos版本
1981年,MS-DOS 1.0发行,作为IBM PC的操作系统进行捆绑发售,支持16k内存及160k的5寸软盘.在硬件昂贵,操作系统基本属于送硬件奉送的年代,谁也没能想到,微软公司竟会从这个不起眼的 ...
- MS DOS 常用命令整理
最近在开发用到一些dos下的一些指令,还有bat文件,特别是bat的便捷性让我在生活和开发过程中好好使用. dos指令: java com.pdcss.util.JacobService > D ...
- Create Script Template In Edit Mode
很多时候 许多类 的 格式 都是重复的,比如 从配置文件中映射出来的类. 这个时候写一个 类模板 就很节省时间了. Code public static string TestPath = " ...
- bat脚本-set(setlocal enabledelayedexpansion) 学习
设置本地为延迟扩展.其实也就是:延迟变量,全称延迟环境变量扩展. 事件一: @echo off set a=4 set a=5&echo %a% pause 解说:为什么是4而不是5呢?在ec ...
随机推荐
- MariaDB ----单表查询
1>按一定条件查询某字段的数据 (where) ; ( 查询 id > 的数据) #补充: ; 注意“ select * from students1: (此命令需谨慎使用, 数据量大 ...
- 异步FIFO的编程
对于异步FIFO.最基本的两个方面是地址控制和空.满标志位的产生.首先地址控制分别为读地址和写地址,每次读写时能读写地址应该加1.计数次数为ram深度的2倍.当读写地址相等时则空标志位有效,当读写地址 ...
- 使用adb在电脑和手机间传文件
首先须要root手机. 然后,"Win + R",打开cmd窗体.以下以copy d:\1.txt到/system/文件夹为例说明. adb push source(localpa ...
- ios打地鼠游戏源代码
打地鼠游戏源代码,游戏是一款多关卡基于cocos2d的iPad打地鼠游戏源代码,这也是一款高质量的打地鼠游戏源代码,能够拥有逐步上升的关卡的设置,大家能够在关卡时设置一些商业化的模式来盈利的,很完美的 ...
- uva 10765 Doves and Bombs(割顶)
题意:给定一个n个点的连通的无向图,一个点的"鸽子值"定义为将它从图中删去后连通块的个数.求每一个点的"鸽子值". 思路dfs检查每一个点是否为割顶,并标 ...
- MySQL-数据库创建与删除
创建数据库 在MySQL中,数据库是用于存储和操作诸如表,数据库视图,触发器,存储过程等数据的对象的集合. 要在MySQL中创建数据库,使用CREATE DATABASE语句,如下: CREATE D ...
- 安装 pip pip 包 安装路径
python2 -m pip install --upgrade pip --force-reinstall pip uninstall pandas pip install --install-op ...
- oracle存储过程和游标的使用
oracle存储过程和游标的使用 (2011-04-19 14:52:47) 转载▼ 游标: 用来查询数据库,获取记录集合(结果集)的指针,我们所说的游标通常是指显式游标,因此从现在起没有特别指明的情 ...
- go语言---for
go语言---for https://blog.csdn.net/cyk2396/article/details/78873930 执行以下代码,发现无法跳出for循环: func SelectTes ...
- P2610 [ZJOI2012]旅游 树的直径
这个题就是建图不太好建,但是我们一想,三角形貌似只能两两挨着,最后会变成一个二叉树,所以问题就变成求树的直径.建图用pair套map超级简单. 题干: 到了难得的暑假,为了庆祝小白在数学考试中取得的优 ...