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
     ---------------------------------------
     
  • 相关阅读:
    java创建节点和单向链表
    Java循环链表实现约瑟夫环(搬运)
    java语言建立顺序表
    顺序表删除重复值的高效算法。
    2016.1.29
    IO流学习笔记
    oracle 计算两个时间之间的月份差,相差几个星期,相差多少天
    java中如何计算两个时间段的月份差
    怎样在数据库中插入大量数据
    oracle 定义数据完整性
  • 原文地址:https://www.cnblogs.com/weihongji/p/3493561.html
Copyright © 2011-2022 走看看