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
     ---------------------------------------
     
  • 相关阅读:
    2020/10/29
    2020/10/24
    2020/10/28
    2020/10/31周报
    linux shell 中判断字符串为空的正确方法
    20201107 千锤百炼软工人
    20201103 千锤百炼软工人
    20201109 千锤百炼软工人
    20201111 千锤百炼软工人
    20201105 千锤百炼软工人
  • 原文地址:https://www.cnblogs.com/weihongji/p/3493561.html
Copyright © 2011-2022 走看看