zoukankan      html  css  js  c++  java
  • EV: DOS batch commands

    echo .

    echo "my comments"

    echo %windir%   显示windows variables/环境变量

    type readme.txt
     
    copy con/IO
    -------------------------
    copy con output.txt Copy from Console to ...
    After you type this command and press ENTER, MS-DOS copies everything you type to the file OUTPUT.TXT. When you are finished typing, press CTRL+Z to indicate that you want to end the file. The Control-Z character will appear on the screen as " ^Z ". You can also end a COPY CON command by pressing the F6 key. Pressing F6 also generates the Control-Z character; a "^Z" still appears on the screen.
    copy con lpt1 Copies information from the keyboard to a printer connected to LPT1
     
    wait/delay/pause
    ---------------------------
    pause
    timeout /t 10
     
    error handle/handling
    ---------------------------------------

    call Batch1.bat
    if %ERRORLEVEL% NEQ 0 goto failed
    echo ...Completed Batch1, %ERRORLEVEL%

    call Batch2.bat
    if %ERRORLEVEL% NEQ 0 goto failed
    echo ...Completed Batch2, %ERRORLEVEL%

    Call Batch3.bat
    if %ERRORLEVEL% NEQ 0 goto failed
    echo ...Completed Batch3, %ERRORLEVEL%

    goto end

    :failed
    echo ....ERROR Please check logs for further details, %ERRORLEVEL%

    :end
    endlocal

    ========================================
    ------------startsql.bat-------------
    @echo off

    if ""%1"" == """" goto startsql
    echo Waiting for %1 seconds...
    sleep %1

    :startsql
    echo Starting sql server service...
    net start MSSQL$SQL2012

    pause

    ------------end of startsql.bat-------------

    ========================================

    REM

    In a batch file REM at the start of a line signifies a comment or REMARK, alternatively adding :: at the start of a line has a similar effect.

    For example:

    @ECHO OFF
    ::
    :: First comment

    REM Second comment
    REM

    Echo Hello REM This remark is displayed by echo
    Echo Hello & REM This remark is ignored by echo

    Copy work.xls backup.xls &:: We backed up the file

    Although you can use Rem without a comment to add vertical spacing to a batch file, you can also use completely blank lines. The blank lines are ignored when processing the batch program.

    The double-colon is not documented as a comment command, it is a special case of a label that acts as a comment.

    An alternative approach is to use plain text and a goto command to jump execution past the comments:

    @Echo OFF
    Goto :START
    Description can go here
    which can even include - | > characters
    
    :START
     ---------------------------------------
     
  • 相关阅读:
    springmvc与servlet初识理解2
    springMVC与servlet的初识
    SpringMVC的依赖和视图解析器配置
    【内网渗透】— 内网信息收集(4)
    机械行业设计软件学习资源整理
    整理的电学课程
    redis src 目录组织结构
    解决Joi报错TypeError: Joi.Validate is not a function问题
    浅谈Node.js开发Web服务器
    JavaScript水仙花数(传递任意n位数)
  • 原文地址:https://www.cnblogs.com/weihongji/p/3493561.html
Copyright © 2011-2022 走看看