Introduction
Who This Book Is For
Even More Help
How This Book Is Structured
Hardware And Software
Writing The Book
Conventions
Last Notes
Chapter 1: Batch Files Are Just Commands For The Operating System
What Are Batch Files Good For?
Keystrokes Reduction
New Command Construction
Consistency
Safety
Windows
Windows 95
OS/2
Summary
Chapter 2: Creating Your Own Batch Files
Operating System Editors
Picking A Name
Internal Commands
Internal CONFIG.SYS Commands
External Commands
MS DOS DOSKEY Macros
How The Operating System Decides Which Command To Run
Summary
Chapter 3: Batch File Construction
Executing Your Batch Files
DOS
Windows
Windows 95
OS/2
Batch File Formatting
Capitalization
Spacing
Indenting Sections
Message Length
Line-Length Limit
Let's Write A Batch File
The Problem
The Solution
A Second Problem
The Solution
Summary
Chapter 4: Documentation Or "Why In The World Did I Do That?"
A Warning
Written Documentation
Even More Documentation
Self-Documentation
Special Information At The Top
Summary
Chapter 5: Let's Keep It Quiet
Command Echoing
Summary
Chapter 6: Communicating With The User
Displaying Messages
Telling The User What Is Going
On
Keeping The User Informed
Giving The User Instructions
Making your messages attractive
Blank Lines
What You Can And Can't Echo
Pipes And Redirection
Percent Sign
On/Off
Longer And Fancier Messages
Background Operation
Summary
Chapter 7: Using High-Ordered ASCII Characters
Entering High-Ordered ASCII Characters
Entering High-Ordered ASCII Characters When Your Editor
Won't Let You
Summary
Chapter 8: Hold That Batch File!
Pausing The Batch File
Aborting The Batch File
Summary
Chapter 9: Applications And Problems
Problem 1
Problem 2
Problem 3
Answers
Chapter 10: Replaceable Parameters
Sending Replaceable Parameters To A Batch File
Using Replaceable Parameters In Your Batch Files
Limits On The Number Of Replaceable Parameters
Some Uses For Replaceable Parameters
Replaceable Parameters As Commands
A Couple Of Examples
Using Replaceable Parameters With OS/2 When Running A Batch
File From The
Desktop
Summary
Chapter 11: Using More Than Ten Replaceable Parameters
The SHIFT Command
What SHIFT Can Do
Using The SHIFT Command
Summary
Chapter 12: Looping And Program Flow
Pseudocode
Naming Program Lines
The GOTO Command
Looping
Transferring Control
Quick Exit With QUIT Command
Handy Formatting Option
Code Separation
Visual Separation
Conditional Execution (Novell DOS 7)
The FOR Command
Looping With The FOR Command
Local Variable
FOR Command Quirks
Summary
Chapter 13: The Environment
The Prompt
The Path
COMSPEC
Environmental Variables
Some Notes On Names
Environmental Variables Are Transient
Putting Variables Into The Environment
Using The Environment In Batch Files
Some Special Novell DOS 7
System Information Variables
Some Special OS/2
Environmental Commands For Saving And Restoring
The Environment
What You Can Do With Environmental Variables
Using The Environment When Shelling Out Of A Program
Environment Problem When
Shelling Out Of A Program
Environment Benefits When
Shelling Out Of A Program
Using The Environment In A Batch File
Summary
Chapter 14: Errorlevel
Summary
Chapter 15: Punctuation
Piping And Redirection
The Available Piping Symbols
Devices To Pipe To/From
How DOS And OS/2 Handle Pipes
Piping And Redirection Must
Use DOS Or OS/2
Filters To Use In Pipes
Problems With Redirection And
Piping
+
:
.
@
%
%%
%Variable%
=
==
Special OS/2 Operators
Summary
Chapter 16: Logic Testing
Are Two Values The Same?
Testing The Errorlevel Value?
Does A File Exist?
Does A Subdirectory Exist?
Earlier Batch File Revisited
A.BAT
RONNYMD.BAT
TOA.BAT
Preview Of Chapter 18
Summary
Chapter 17: Applications And Problems
Problem 4
Problem 5
Problem 6
Answers
Chapter 18: Advanced Logic Testing
NOT
Inter-Batch Communications
Dealing With Capitalization
GOTO %1
Environmental Variables
The Path (DOS Only)
Run A Program
Capitalization Conclusion
Multiple IF-Tests
Novell DOS 7
A Shorter Way To Show The Errorlevel
A Very Short Way To Show The Errorlevel (DOS Only)
Setting The Errorlevel (DOS)
Setting The Errorlevel (OS/2)
Help
Summary
Chapter 19: Advanced getting information from users
CHOICE
OS/2
Summary
Chapter 20: Advanced Screen Design 1
Text files
Writing A Program
Using A Screen Compiler
ANSI
Summary
Chapter 21: Advanced Screen Design 2: ANSI.SYS
Ansi Under DOS
Ansi Under OS/2
Getting Started With Ansi
Entering Ansi Commands
Word Processors, Editors, And The Problem Of
"Escaping"
Sending Ansi Commands By Typing A File
Sending Ansi Commands Using The Environment
Sending Ansi Commands Via The Prompt
Screen Control
Cursor Control
Video Control
Keyboard Control
An Example
Summary
Chapter 22: Batch File Subroutines
What Is A Subroutine, And How Do I Write One?
As A Separate Batch File
Prior To MS DOS 3.3
DOS 3.3 And Later
An Example
Inside The Calling Batch File
Storing Subroutine Commands Within A Batch File
DR DOS 6 And Novell DOS 7
Summary
Chapter 23: When Batch Files Don't Work
Possible Error Messages
Syntax Error
Bad Command Or Filename
Command Or Filename Not Recognized
Label Not Found
Abort, Retry, Ignore, Fail?
Abort, Ignore, Retry Abort, Retry, Fail Data
Error Drive Not Ready Physical
Media Error Sector Not Found
Access Denied
Batch File Missing Batch file
... missing retry [Y/N]?
Batch Files Nested Too Deep
Not Enough Memory Not Enough
Memory For ... Not Enough Memory To ...
Not Ready Error
Cannot Start Command, Exiting
No Free File Handles/Cannot Start
Command, Exiting Too Many Files Open Too Many Open Files
Environment Full
Environment Error
Filename Too Long
Disk Full
Write Protect Error
File Sharing Conflict
On Or Off Parameter Required
Invalid Path Or Path Not Found
Invalid Path Specified: Check Path
Other
Check The Spelling
Look Closer
Step Through The Batch File
Isolate The Problem
Split Out The Problem Section
Diagram The Logic
Put It Aside For A While
Start Over
Summary
Chapter 24: Applications And Problems
Problem 7
Problem 8
Problem 9
Answers
Chapter 25: An Automated Batch File Help System
Help Files
Customized Help
Context-Sensitive Help
Summary
Chapter 26: Batch File Menus (DOS Only)
Introduction To Menus
Displaying The Menu
Types Of Menus
Non-resident Non-Nested Menus
Resident Non-Nested Menus
Hybrid Batch File
Stand-Alone Batch File
Nested Menus
DR DOS 6 And Novell DOS 7 Menus
Summary
Chapter 27: A Document Archival System
Periodic Backups
Which File To Back Up?
Types Of Backup
Systematically Copy Critical Data Files
Never Delete Old Files!
Index Document Files
Summary
Chapter 28: Simulating Doskey Using Batch Files
Command Line Macros
Command Line Recorder
Running Multiple Commands
Summary
Chapter 29: Smaller Batch File Applications
Maintaining Your C:\BAT Subdirectory
Screen Saver
Is Windows Running?
Changing Subdirectories
Running Inflexible Programs
Finding Files
Running Commands Occasionally
Using The Volume In A Batch File
Batch File Floppy-disk Catalog
Adding To And Deleting From Your Path (DOS Only)
Password Protection (DOS Only)
Determining Codes To Use With The Password Batch File (DOS
Only)
Summary
Chapter 30: Applications And Problems
Problem 10
Problem 11
Problem 12
Problem 13
Answers
Chapter 31: Writing Your Own Batch File Utilities (DOS And Windows)
What Is A Batch File Utility?
What It Needs
QuickBASIC
Adding One To Command Line
Number
Multiplying Two Numbers
Together
Builder And Builder Lite
Adding One To Command Line
Number
Multiplying Two Numbers
Together
Turbo Pascal
The EnvLib Library Unit
Adding One To Command Line
Number
Adding One And Letting The
User Pick The Environmental Variable
Multiplying Two Numbers
Together
Windows 3.1
Summary
Chapter 32: Writing Your Own Batch File Utilities (OS/2)
REXX Programming
Background
Introduction
Variables And Branching
Logic Testing And Looping
Subroutines
Batch File Utilities In Rexx
A Brief Word On Licensing
Getting Information From The
User
Did The User Request Help
Batch File Utilities In VX*REXX
BATHELP.EXE
SCAN.ERX
Other REXX Utilities
Summary
Chapter 33: Modifying MS DOS With DOSKEY And Batch Files
DOSKEY Basics
What Can I Do With DOSKEY?
Putting It Together
Command Line Recall
I've Had It!
Summary
Chapter 34: Getting Input From The User (DOS)
First A Note...
Answer
Askit
BatKit
Capital
Hold
GetKey
Getkey
GETSET
ISITWIN.EXE
NEEDHELP.EXE
Opal Batch Organizer and Extender
Y_OR_N
Chapter 35: Communicating With The User (DOS)
First A Note...
Ansihere
ASCII.EXE
BatScreen
Cleave
EQO
GetColor
Press Any Key
Text Font
TurboTXT
VGA Clear Screen
Chapter 36: Menu Programs (DOS)
Amenu
Choose
DRMENU
Menu_Man
ENVIMENU
Hard Disk Menu System
Sparkle & Menu Magic
Sparkle-2
Chapter 37: Dealing With Files, Disks, and Subdirectories (DOS)
First A Note...
CFGCNTRL
CHKPARM
DelEx
DIR2BAT
ForAge
ISITZERO
PocketD Plus
QIC-BAT for CMS
StripX
Chapter 38: Batch File Utilities Sets (DOS)
A BATCH VIEW
Batch Environment
BATCHMAN
Batcmd 1.1
Single-Character Response
Questions
Multiple-Character Response
Questions
The Remaining Commands
BATUTIL 4.0
CFG
DOS Tool Box
Scanion Enterprises Batch File Utilities
Steenburgh's Stuff
Ultra ToolBox
Utility_Belt
XSET
Chapter 39: Other Batch File Utilities (DOS)
CAPSTAT
CONTROLP
CRONTAB
DAYSLEFT
DO-FOR
DO-ONCE
DVRUN
Envi_Man
Everyday
FDATE
FREEFILE
GET.EXE
Go
HOLDON
Interval
KBSTUFF
KeyToggle
MakeName
Multi-Print
ONEADAY
Path Master
Path_Man
QTOD
QuickBATCH
Ram-Man
Scan
See
SetEr
Sound Effects
STACKEY
Summit
Video FX
Chapter 40: Alternative Batch Languages (DOS)
Please Read This
Bat2Exec
Compiling a batch file
Problems
Builder
Operation
Command Extensions
Using The Compiler
Builder Extensions
Builder Lite
CEnvi
PB Plus+ PowerBatch
Installation
Getting Started
Using The Compiler
Drawbacks
Personal REXX
TurboBAT
Chapter 41: Windows Batch File Utilities
%COMSPEC%
IsItWin
SmilerShell
WinEdit
Chapter 42: Windows Alternative Batch File Languages
CEnvi
Personal REXX
WinBatch
A Simple Example
The WinBatch Language
Other Components
Conclusion
WinBatch Compiler
WINCMD
Chapter 43: OS/2 Batch File Utilities
CEnvi
CRONTAB
Personal REXX
QTOD
REXXLIB for OS/2
Wpsbkup
© 2002 by Ronny Richardson, All Rights Reserved