Batch Files

Batch Files

  1. Batch File Basics
    @ECHO
    REM
    ECHO

  2. Working with a Text Editor
    Why use a Text Editor?
    Syntax highlighting
    Text formatting
    UTF-8 encoding ~= ASCII
    Newline issue

  3. Basic Batch File Commands
    REM
    ECHO
    GOTO
    IF
    START
    %n passing parameters (0-9)

  4. REM Command (Internal)
    Name of batch file
    Date
    Author
    Description

  5. ECHO Command (Internal)
    ECHO text
    ECHO ON | off
    ECHO.
    @
    @ECHO OFF

  6. ECHO Example
    Text top of screen
    Results of DIR

  7. Replaceable Parameters
    %0 batch file
    %1 - %9 replaceable parameters

  8. Replaceable Parameters Example
    DEMO.BAT com
    The extension is com
    DIR of *.com

  9. GOTO Command (Internal)
    :label
    GOTO label

  10. GOTO Example
    Ctrl-C to terminate

  11. IF Command (Internal)
    IF "text1" == "text2" GOTO label
    IF [NOT] EXIST filename GOTO label
    IF [NOT] ERRORLEVEL n GOTO label

  12. IF Example
    IF "%1" == "" GOTO err_msg
    :err_msg
    :end

  13. START Command (Internal)
    "title"
    path
    /MAX
    /MIN
    /WAIT

  14. START Example
    START music
    START firefox -switch URL

  15. GUI shortcut to batch file
    Target
    Start in
    Run (size of window)
    Change Icon

  16. Is DOS Dead?
    iexplore.exe -nohome
    file://%1