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 ...
随机推荐
- onenstack 简介
一.云计算的前世今生 所有的新事物都不是突然冒出来的,都有前世和今生.云计算也是IT技术不断发展的产物. 要理解云计算,需要对IT系统架构的发展过程有所认识. 请看下 IT系统架构的发展到目前为止大致 ...
- Mariadb 主从
一 mariadb主从多用于网站架构,因为该主从的同步机制是异步的,数据的同步有一定延迟,也就是说有可能会造成数据的丢失,但是性能比较好,因此网站大多数用的是主从架构的数据库,读写分离必须基于主从架构 ...
- ASP.NET MVC Model之二模型绑定
Asp.net mvc中的模型绑定,或许大家经常用,但是具体说他是怎么一回事,可能还是会有些陌生,那么,本文就带你理解模型绑定.为了理解模型绑定,本文会先给出其定义,然后对通过比,来得出使用模型绑定的 ...
- 《ASP.NET4 从入门到精通》学习笔记4
第4部分诊断与插件 刚開始看这章的时候,真实一头雾水.不知道在讲什么.只是看了关于http pipeline之后.才了解相关说明. 因此对于这一章的学习,建议各位首先看看http pipeline然后 ...
- Spring Boot Controller
接上篇文章.HelloWorld程序中我们已经创建了一个HellController,里面包括了响应JSON的方法.本文针对Controller再做一下解说. 回想上篇文章,我们在Controller ...
- YTU 2520: 小慧唱卡拉OK
2520: 小慧唱卡拉OK 时间限制: 1 Sec 内存限制: 128 MB 提交: 478 解决: 207 题目描述 小慧唱歌非常好听,小鑫很喜欢听小慧唱歌,小鑫最近又想听小慧唱歌了,于是小鑫请 ...
- 7-81 js课程小结
7-81 js课程小结 学习要点 理解全局对象 变量的作用范围 理解全局对象Global 全局属性和函数可用于所有内建的 JavaScript 对象.全局对象是所有全局方法的拥有者,用来统一管理全局方 ...
- ASP.NET和C#的区别/
1..NET是一个平台,一个抽象的平台的概念. .NET平台其本身实现的方式其实还是库,抽象层面上来看是一个平台. 个人理解.NET核心就只是.NET Framework. .NET Framewor ...
- [翻译]NUnit--前言(一)
前言: 翻译这个系列主要是自己在学习NUnit之时看英文文档大部分能看懂但是有些还是功底不足,所以在方便自己以后再学习的时候可以快速查找,也能够加深印象以及掌握的更好.同时在搜索网上关于NUnit系列 ...
- 【POJ 3352】 Road Construction
[题目链接] 点击打开链接 [算法] tarjan算法求边双联通分量 [代码] #include <algorithm> #include <bitset> #include ...