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 ...
随机推荐
- Myeclipse的优化方法
近期在实习,公司给分配了新的电脑,可是不知道怎么弄得,总是弄得非常卡,没办法仅仅有自己好好整理一下电脑了,另外.为了提高编程的效率.顺便也把Myeclipse也优化了一下. 第一步: 取消自己主动va ...
- iOS单例设计模式具体解说(单例设计模式不断完好的过程)
在iOS中有非常多的设计模式,有一本书<Elements of Reusable Object-Oriented Software>(中文名字为<设计模式>)讲述了23种软件设 ...
- JspSmartUpload 实现上传
2.save 作用:将所有上传文件保存到指定文件夹下,并返回保存的文件个数. 原型:public int save(String destPathName) 和public int save(St ...
- JFreeChart生成饼形图(3)11 (转自 JSP开发技术大全)
FreeChart生成饼形图(3) (转自 JSP开发技术大全) 14.3 利用JFreeChart生成饼形图 通过JFreeChart插件,即可以生成普通效果的饼形图,也可以生成3D效果的饼形图:如 ...
- 【Codevs 1376】帕秋莉•诺蕾姬
http://codevs.cn/problem/1376/ 枚举修改哪两位,将sum减去之前位置的数+交换之后 %m==0即可 预处理26的次方+O(n^2) // <1376.cpp> ...
- poj1286 Necklace of Beads—— Polya定理
题目:http://poj.org/problem?id=1286 真·Polya定理模板题: 写完以后感觉理解更深刻了呢. 代码如下: #include<iostream> #inclu ...
- 2-3 Vue实例中的数据,事件和方法
上节课模板是写在Vue的实例里面的,现在我们可以把它恢复出来.写在挂载点的内部,看起来会舒服一点.Vue的数据项,可以配置任意的数据名字. <!DOCTYPE html> <html ...
- Rails5 View Document
更新: 2017/06/11 更新: 2017/06/15 加粗,submit必须放在form_for内部 更新: 2017/06/23 对待完成的追加# TODO: ...
- bzoj 1087: [SCOI2005]互不侵犯King【状压dp】
显然是状压,设f[i][j][k]为1到i行选j个king,并且第i行状态为k的方案数,判断是否可行然后枚举转移即可 先把可行状态预处理出来会变快 #include<iostream> # ...
- bzoj 3396: [Usaco2009 Jan]Total flow 水流【最大流】
最大流生动形象的板子,注意数组开大点 #include<iostream> #include<cstdio> #include<queue> #include< ...