Batch Files
Batch Files
- Batch File Basics
@ECHO
REM
ECHO
- Working with a Text Editor
Why use a Text Editor?
Syntax highlighting
Text formatting
UTF-8 encoding ~= ASCII
Newline issue
- Basic Batch File Commands
REM
ECHO
GOTO
IF
START
%n passing parameters (0-9)
- REM Command (Internal)
Name of batch file
Date
Author
Description
- ECHO Command (Internal)
ECHO text
ECHO ON | off
ECHO.
@
@ECHO OFF
- ECHO Example
Text top of screen
Results of DIR
- Replaceable Parameters
%0 batch file
%1 - %9 replaceable parameters
- Replaceable Parameters Example
DEMO.BAT com
The extension is com
DIR of *.com
- GOTO Command (Internal)
:label
GOTO label
- GOTO Example
Ctrl-C to terminate
- IF Command (Internal)
IF "text1" == "text2" GOTO label
IF [NOT] EXIST filename GOTO label
IF [NOT] ERRORLEVEL n GOTO label
- IF Example
IF "%1" == "" GOTO err_msg
:err_msg
:end
- START Command (Internal)
"title"
path
/MAX
/MIN
/WAIT
- START Example
START music
START firefox -switch URL
- GUI shortcut to batch file
Target
Start in
Run (size of window)
Change Icon
- Is DOS Dead?
iexplore.exe -nohome
file://%1