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 ...
随机推荐
- 利用vue-cli配合vue-router搭建一个完整的spa流程
好文章备忘录: 转自:https://segmentfault.com/a/1190000009160934?_ea=1849098 demo源码:https://github.com/1590123 ...
- LVS 负载均衡 (VS/DR模式 与 VS/TUN 模式)
一.VS/DR模式 ①.客户端将请求发往前端的负载均衡器,请求报文源地址是CIP,目标地址为VIP. ②.负载均衡器收到报文后,发现请求的是在规则里面存在的地址,那么它将目标MAC改为了RIP的MAC ...
- Android 代码设置Activity 背景透明
当指定Activity 样式 Them.Dialog 时候 又不同意用XML 设置 Activity 的背景颜色的时候 用代码 this.getWindow().getDecorView().setB ...
- Enterprise Library 5.0 学习笔记
近期了解了微软提供的企业开发框架Enterprise Library,眼下最新版本号是6.0,可是不支持FW3.5.所以就学习了5.0的版本号,EL5.0支持FW3.5和4.0,官网下载地址是:htt ...
- iOS MMDrawerController源码解读(一)
提前说好,本文绝对不是教你如何使用MMDrawerController这个第三方库,因为那太多人写了 ,也太简单了.这篇文章主要带你分析MMDrawerController是怎么实现抽屉效果,明白 ...
- Sqoop异常解决ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: No columns to generate for ClassWriter问题
问题详情如下: 解决办法 这个是由于mysql-connector-java的bug造成的,出错时我用的是mysql-connector-java-5.1.10-bin.jar,更新成mysql-co ...
- ci完整集成
http://www.cnblogs.com/zhanchenjin/p/5032218.html http://blog.csdn.net/williamwanglei/article/detail ...
- Could not find modernizr-2.6.2 in any of the sources GitLab: API is not accessible
Could not find modernizr-2.6.2 in any of the sources GitLab: API is not accessible bundle exec rake ...
- E20171225-hm
abstract adj. 抽象的,理论上的; 难解的; 抽象派的; 茫然的;
- Juicer.js模板引擎问题
由于jsp中的EL表达式语法和jquery.tmpl十分类似,,所以单纯的使用${name},数据是渲染不上tmpl的. SO.. 要加上转义: ${'${'}amount} 或者 \${amount ...